How to select a piece of text and paste it at the current cursor position without using a mouse in vim?

I want to stop using the mouse to select and paste pieces of text into the clipboard. What is the most efficient way to do this with kb? I mean going to an arbitrary line, copying a substring, returning to the previous position and pasting.

+4
source share
6 answers

If you want to quickly jump to a line, use the search by typing /SUBSTRING and then Enter after you find the correct substring. Be sure to use hlsearch and incsearch :set incsearch and :set hlsearch

When you are on the right line, keep the whole line with yy or the whole word yaw . Then go back to where you started the search by typing two backticks `` Then you can insert your pulled string / string with p

+5
source

A very simple method:

  • Select rows with Shift-V
  • Yankees (= copy) text with y
  • Paste the text with p in the place you want.

There are, of course, many other ways to copy and paste, yy copies the current line, for example.

Do a few VIM tutorials, this is better than learning different things.

+4
source
  • Mark your current position by typing ma (you can use any other letter instead of a, it's just "name case by name".
  • go to string and substring, for example using / search
  • hold the text with y<movement> or mark it shift/ctrl-v and then y
  • return to the previously marked position with `` a`` (backtick)
  • insert your buffer with p or p
+3
source

My usual method:

  • Use visual mode to select text with v , v or Ctrl + v
  • Using Yank with y
  • Scroll to the line where you want to use 123G or :123
  • Go where I want to be in this line with t or f
  • Put text with p or p

If you need to jump back and forth between the spots, I would go through the jumps using g , and g ; .

+3
source

Use "p" to insert after the current line and "P" to insert above the current line.

+1
source

Not sure what you mean by "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.
+1
source

Source: https://habr.com/ru/post/1302477/


All Articles