Inserting text in multiple lines

参考:http://vim.wikia.com/wiki/Inserting_text_in_multiple_lines
In visual block mode, you can press I to insert text at the same position in multiple lines, and you can press A to append text to each line in a block. As well as inserting or appending text that you type, you can insert or append text from registers, for example, the clipboard. The substitute command can also be used to insert or append text.

For example, suppose you have some Vim script:

let a = 2
let b = 3
let c = 4
You may want to make these variables script-wise (by inserting "s:" before each variable name, so "a" becomes "s:a" etc). To do this, move to the a in the first line, then press Ctrl-V (or Ctrl-Q if you use Ctrl-V for paste), then jj to select a visual block over three lines.

Now type I to start a special form of insert mode, then type the wanted text (s:). When you press Esc to exit from insert mode, the text will be inserted in the same position on each of the lines affected by the visual block selection.

posted @ 2016-04-19 12:51  qike  阅读(246)  评论(0编辑  收藏  举报