Am 22.05.2012 18:03, schrieb AndyHancock:
I am working on a source code file with many blank lines (lines
containing zero characters, not even white space).  The cursor is on
(say) column 5 and I press ctrl-V before highlighting a column of
text.  I then press ctrl-I to insert a comment character in the
highlighted text column.  The comment character does *not* appear at
all in the lines that are blank.

I could be mis-remembering, but I don't seem to recall this behaviour
in the past.  I thought I had vim in a mode where ctrl-V would put in
the required white space to achieve the visual effect, regardless of
whether or not the whitespace was there before.  Is this a recent
change in the behaviour of vim, or is there a specific setting which I
might have muddled up in my romps through vimrc?

I checked with gVim 6.4: <C-V>I  behaves in same fahsion.
But you can do  r{char}  with  virtualedit=all  to fill in whitespace.

Here is a mapping that does this for the `I' command:


xno <script><expr> I mode()=="<C-V>" ? 'Ix<Esc><SID>(sve)gvrxgv"_x<SID>(rve)gvI' : 
"I"

" set/restore 'virtualedit'
nn <SID>(sve) :<C-U>call <sid>sr_ve(1)<CR>
nn <SID>(rve) :<C-U>call <sid>sr_ve(0)<CR>

func! <sid>sr_ve(save)
    if a:save
        if &ve != 'all'
            let s:save_ve = &ve
            set virtualedit=all
        endif
    elseif exists("s:save_ve")
        let &ve = s:save_ve
        unlet s:save_ve
    endif
endfunc


You may set 'lazyredraw' to reduce visual glitches.
Offhand I don't remember an option to control this, I may be wrong ...
It's just a workaround.

--
Andy

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to