(Change <tt> to <code>, perhaps also minor tweak.)
Line 4:
Line 4:
|previous=733
|previous=733
|next=735
|next=735
−
|created=May 27, 2004
+
|created=2004
|complexity=basic
|complexity=basic
|author=Yakov Lerner
|author=Yakov Lerner
Line 12:
Line 12:
|category2=
|category2=
}}
}}
−
This tip is useful only for those who use virtualedit mode (<tt>set virtualedit=all</tt>, or <tt>set ve=all</tt>).
+
This tip is useful only for those who use virtualedit mode (<code>set virtualedit=all</code>, or <code>set ve=all</code>).
−
I like virtualedit mode except for behaviour of '<tt>x</tt>' (delete character). When '<tt>x</tt>' is used past end-of-line, it does nothing. I wanted it to jump left to the actual end-of-line so as to start deleting characters there. Below is '<tt>x</tt>' redefinition that does exactly this; and it does not break '<tt>x</tt>' in non-virtualedit mode:
+
I like virtualedit mode except for behaviour of '<code>x</code>' (delete character). When '<code>x</code>' is used past end-of-line, it does nothing. I wanted it to jump left to the actual end-of-line so as to start deleting characters there. Below is '<code>x</code>' redefinition that does exactly this; and it does not break '<code>x</code>' in non-virtualedit mode:
<pre>
<pre>
Latest revision as of 05:45, July 13, 2012
Please review this tip:
This tip was imported from vim.org and needs general review.
created 2004 · complexity basic · author Yakov Lerner · version 6.0
This tip is useful only for those who use virtualedit mode (set virtualedit=all, or set ve=all).
I like virtualedit mode except for behaviour of 'x' (delete character). When 'x' is used past end-of-line, it does nothing. I wanted it to jump left to the actual end-of-line so as to start deleting characters there. Below is 'x' redefinition that does exactly this; and it does not break 'x' in non-virtualedit mode:
" redefine x for virtualEdit so that past end of line, it jumps left to end-of-line
function! Redefine_x_ForVirtualEdit()
if &ve != "" && col('.') >= col('$')
normal $
endif
endfu!
silent! unmap x
:nnoremap <silent>x x:call Redefine_x_ForVirtualEdit()<CR>