Multiple Choice in VIM

Is it possible to select multiple disjoint lines (or sections) in visual VIM mode? If so, how?

+55
vim selection
Oct 22 '09 at 15:52
source share
3 answers

You need to install the multiselect plugin to get this feature. Find it here: http://www.vim.org/scripts/script.php?script_id=953

+28
Oct 22 '09 at 16:05
source share

No, this is not possible without plugins.

But you can copy multiple lines to the same buffer if this solves your problem.

  • To run Cumulative Buffer:
    • mark the section for copying in visual mode,
    • press "a to work with buffer a with the following command and
    • keep it as usual ( y ).
  • To add to this buffer:
    • check the next section and
    • press "a (the buffer header name means" do not overwrite the buffer, add it instead ")
    • and yank again using y .
  • You can then insert the accumulated buffer a at any time using "ap .
+57
Oct 22 '09 at 16:03
source share

A more modern answer is this plugin .

(disclaimer: I personally do not actually use it, it interferes too much with the rest of my vim installation. If your vim is relatively clean and you are moving from the sublime, this could certainly be your cup of tea.)

I would also like to indicate the vim recording / playback functionality ( q key). Often, recording is also not needed, I can perform tasks that are usually performed using sublime multiple selection, performing iteratively (for example, search for something, perform corrections in the first instance, and then repeat subsequent repetitions by pressing n and n to move and . to repeat the editing operation).

I have mine , comma nnoremap 'd to @q , this repeats the sequence recorded by pressing qq (writing to q register).

+21
May 15 '13 at 15:06
source share



All Articles