Reputation: 455
I'm switching my TextEditor from Sublime Text to Vim with iTerm2 recently.
I'm looking for a plugin to paste text in Multiple Position of Multiple Line on Vim.
(Similar to the multicursor on Sublime Text which I can select cursor and use CMD+Click to select in other position then paste.)
I've seen vim-multiple-cursors plugin but it will only allow me to select the same word of next occurrence.
e.g - to place cursor at different location on different line as below.,
Line 1: Lorem ipsum dolor sit amet, [CURSOR HERE] consectetuer adipiscing elit. Aenean
Line 2: commodo ligula [CURSOR HERE] eget dolor. Aenean massa. Cum sociis natoque
Line 3: penatibus et magnis dis parturient montes,[CURSOR HERE] nascetur ridiculus mus.
Line 4: Donec [CURSOR HERE] quam felis, ultricies nec, pellentesque eu,pretium quis, sem.
Your help would be greatly appreciated and Many Thanks in advance.
VIM Version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Apr 21 2014 14:54:22)
MacOS X (unix) version
Upvotes: 2
Views: 1002
Reputation: 196546
The canonical Vim way to do that, the "dot formula" as coined by Drew Neil, is the reverse of the Sublime Text way.
In Sublime, you mark each match of a pattern, before doing the change :
mark Cmd+D
mark Cmd+D
mark Cmd+D
mark Cmd+D
change foo
In Vim, you "mark" a pattern, do the change once and repeat it on further instances of that pattern:
mark *N
change ciwfoo<Esc>
repeat n.
repeat n.
repeat n.
But, since you have 7.4, you can use the "new" gn
normal mode command/motion:
nnoremap <key> *``cgn
and shorten the process above to:
change <key>foo<Esc>
repeat .
repeat .
repeat .
repeat .
Which is not that bad, I think.
Upvotes: 2
Reputation: 21
Vim has a different buffer that stores what you have copied. To paste you just have to use "P" and the content is pasted.
Or I would recommend you to use "." [dot] - in Vim it is used for last action. So, once you have written/copied and pasted it in one line, you can just use the "dot" everywhere you want the same text to be pasted (i.e. last action to be taken).
Upvotes: 2
Reputation: 172560
I recommend against trying to port your previous editing habits unchanged to Vim; after all, Vim's mode-based editing and command-based syntax are its distingishing features and make editing highly efficient.
The "Vim way" would be more like using a regular expression to specify the places, moving to the first match, pasting, and then repeating with n
and .
You can sort-of emulate your intended workflow by manually inserting a marker char (e.g. §
) at each location, and then replacing it via:
:%s/§/\=@@/g
This uses :help sub-replace-expr
to replace with the default register's contents.
Upvotes: 3