Reputation: 16065
I want to give up using mouse for selecting and pasting chunks of text within a buffer. Whats the most efficient way to do this with just kb? I mean navigate to arbitrary line, copy the substring, return to the previous position and paste.
Upvotes: 5
Views: 1396
Reputation: 603
If you want to go quickly to a line use the search by typing
/SUBSTRING
and then Enter after you have found the correct substring.
Make sure to use hlsearch and incsearch
:set incsearch
and :set hlsearch
When you are at the correct line, yank the whole line with yy
or the whole word with yaw
.
Then go back to where you started the search by typing two backticks ``
Then you can paste your yanked line/string with p
Upvotes: 5
Reputation: 212178
Not sure what you mean by 'the substring'. If you want to copy line 50 to the current position, use:
:50t.
If you want to move line 50 to the current cursor position, use:
:50m.
Upvotes: 1
Reputation: 40927
My normal method would be:
123G
or :123
If you need to jump back and forth between the spots, I'd cycle through jumps using g, and g;.
Upvotes: 3
Reputation: 12971
ma
(you can use any other letter instead of a, this is just a "named position register"./
searchy<movement>
or mark it with shift/ctrl-v
and then y
p
or P
Upvotes: 3
Reputation: 28268
Very simple method:
Shift-V
y
p
at the position you want to.There are of course many other ways to copy and paste, yy
copies the current line for example.
Do the some VIM tutorials, it is better than learning everything bit by bit.
Upvotes: 5
Reputation: 12009
Use "p" to paste after the current line, and "P" to paste above the current line.
Upvotes: 1