Align an area in VIM without moving the cursor to the top of the block?

Is there a simple way (i.e., without writing a script or a complex sequence of keys) to let the Yankees group the lines and leave the cursor wherever the Yank was executed, as opposed to the start of the block?

According to VIM help: "Note that after the yank character command, Vim leaves the cursor on the first twitching character, which is closest to the beginning of the buffer." It seems that the behavior behaves in a similar way.

This annoys me a bit, since I prefer to select a large area from top to bottom, Yank, and then paste near or below the bottom of the selected area. Today I set the (mx) sign directly in front of the Yank and then jump back, but I suspect there might be another Yank sequence that will do what I need.

I have searched SO and the Internet for this many times. There are so many existing โ€œVIM shortcutsโ€ materials to make their way, but I have not yet found a solution for this.

Thanks in advance.

+41
vim
Sep 27 '10 at 18:18
source share
5 answers

Not quite answering your question, but maybe '] will solve your problem?

  '] `] To the last character of the previously changed or yanked text. {not in Vi} 
+46
Sep 27 '10 at 18:29
source share

If you use visual blocks ( v ), then after capturing the block, you can use gv to reselect the same block (which also moves the position of your cursor back to where it was before pulling it out). If you then press Esc, the block will not be selected without moving the cursor.

The ctrl-o command in the visual block mode, which jumps between the beginning and end of the selected block, can also be interesting.

+26
Sep 27 '10 at 18:26
source share

:y3 will pull three integer lines from the current current line. If you know exactly how many lines to pull out, this command is very convenient. :help :yank for details.

:%y will select the entire buffer without moving the cursor, for example ggvG$y , without highlighting the selection and changing the case "* .

I use this insert mode map:

 function! SelectAll() %y* endfun imap <expr> <F3> SelectAll() 

ps: if you want to <CV> insert (outside vim) use %y+

check overflow https://stackoverflow.com/a/4188268

+1
Jan 12 '14 at 13:04 on
source share

If you are twitching in visual mode, you can also use '> or `> to go to the last line / character of the highlighted visual highlight just. In this context, these are essentially the same as '] and `] , which apparently are not supported, for example. in VsVim.

+1
Aug 16 '16 at 20:20
source share

I am not sure if YankRing changed after the vmap ygv<Esc> solution was sent, but this did not vmap ygv<Esc> for me after adding it to my .vimrc . YankRing actually rewrote it.

Here is my solution in .vimrc .

 function! YRRunAfterMaps() vmap y ygv<Esc> endfunction 
0
Apr 28 '14 at 20:03
source share



All Articles