Wednesday, April 2, 2008
Visual Block Change
In Vim, you can replace a selected portion of text across multiple lines with a new piece of text using a Visual-block change. As an example, highlight a portion of text across multiple lines using ctrl-v (blockwise visual mode), now press the "c" key to delete the selected text and enter insert mode. Type in some new text and press the Esc key. The text should be inserted for each row of the selection.
Subscribe to:
Post Comments (Atom)
6 comments:
If you just want to insert and not replace, use I, "insert", instead of c after the visual block selection is made. I use that a lot to insert comments in front of a contiguous group of lines.
Just to be clear, I meant to use "I" as in capital 'i', the letter that comes after H in the roman alphabet.
Ooh, very cool! I didn't know this but will definitely be incorporating it into my repertoire of regularly used commands.
Thanks!
You can also block append to lines, using A instead of I. Depending on how the block was selected, it will append to the end of every line reguardless of line length, and in another case, insert whitespace.
http://vimdoc.sourceforge.net/htmldoc/visual.html#v_b_A
insert is better
Wow. VIM maybe powerful, but the commands are just akward. Pressing Esc to apply a command on multiple line instead of aborting the command is just really wierd.
Post a Comment