views:

396

answers:

2

Is it possible to select multiple non-consecutive lines (or sections) in VIM's visual mode? If so, how?

+8  A: 

No, this is not possible without plugins. But you can copy multiple lines into the same buffer, if that solves your problem. You mark a section to copy in visual mode, press "a to operate on the buffer a with the next command and yank it as usual (y). Then you mark the next section and press "A - capitalizing the buffer name means "do not overwrite the buffer, append to it instead" - and yank again using y. You can then paste the accumulated buffer a at any time using "ap.

soulmerge
I wish I could accept two responses. This is good to know too. Thank you.
Marcin
If you would remove that "No this is not possible" bit, then I would upvote this answer.
Michael Dillon
Not actually removed, but adjusted first sentence. Should be correct now.
soulmerge
+9  A: 

You have to install the multiselect plugin to get this capability. Find it here: http://www.vim.org/scripts/script.php?script%5Fid=953

Michael Dillon