I can do a search to highlight multiple unrelated words that exist with:


But this is only search, it is not "select" (for copy and paste operation)

How to highlight multiple unrelated sentences ?

  1. As in web browser, I can highlight any lines of sentences or any words and line mix that is not on the same line (by holding down "shift key"), to copy them , so that i can paste them into an empty space.

Like so: do a multi select multi select I have a huge note of all important event taken place daily. When i browse thru the note,i want to extract out all the related events that i need, and paste it into an empty space (to group them together, instead of scattered all around). I was thinking maybe vim have the same capability as in browser, to multi select for copy and paste.

If vim don't have such function, how do you do such a task ? For example, the txt file is 100 pages long, i am somewhere in the middle of the page (where the search landed me). I can see multiple lines, scattered around on my screen that are of my interest. I want to copy them and paste them to an empty space of the file (which is at the bottom of the 100 pages file) or paste into new file in splited window. I can't just copy one line then go to bottom of the page to paste and then come back to the same screen to repeat for the rest of the lines, because on the current screen itself has already got 10 lines of interest, and if i scroll down 1 page, there will be another several lines... and the list might goes on for many more pages.. if i just copy 1 line and paste and return to the same place to look for where did i just copied just to copy another line, there will be huge confusion and not productive. If (like in web browser) i can use "shift key" to multi select as i go, it will be faster, i can copy all the lines of interest from current screen and paste once only.. the i can page down to repeat ..

Thxenter image description here

Sorry, my previous post was lacking in clarification. It was closed, hence i repost here.

Is there such a feature in vim : I has got tags, such @result @plan @action @analyze etc in the text file. Is it possible that Vim will shows me all the lines that containt the Tag that i want only; any line that is not have the @tag , will not be display or will not be selected. In this can, i can easily list out only all the line of a certain @tag.

  • If there is no multi selection function in vim, how you copy multiple scattered sentences or words on screen ? Thx Mar 12, 2021 at 19:00
  • Related, possible dupe: vi.stackexchange.com/q/4307/10604. (For copy, something like qqq to clear the q register and then :global/pat/yank Q or :…/normal! "Qy…, but also just :global/pat/to … and similar)
    – D. Ben Knoble
    Mar 12, 2021 at 19:14
  • D.Ben Knoble, The link you gave me is very confusing. Don't understand, somehow it is multiple cursor, but no multiple selection ? (or the "cursor" in the link actually equal to selection? ) What's is your way to do such a task ? copy and paste a line each time ? for the whole text ? is there any better or more efficient way of doing it ? Thx Mar 12, 2021 at 20:37
  • I’m not entirely clear that I’ve understand your workflow, but if you find jumping around disorientating, you may want to take a look at either using the jump list or using a vertical split with the bottom of the same file in the other split. Mar 12, 2021 at 21:11
  • 1
    I'll post a longer answer which might help, rather than continue this discussion in comments. Your question at the end about displaying only certain lines is a separate question, please make a new post as vi.se intends for one question per post. Mar 12, 2021 at 21:53

1 Answer 1


If you want to copy multiple separate words and paste them at the end of a long document, here are some options.

Option 1: splits

You can open the same buffer side-by-side using :vsplit. You can then jump between the two using window motions such as CTRL-WCTRL-W. So a workflow might look like this:

  1. :vsplit to open the same buffer in a vertical split
  2. G to go to the bottom of the file
  3. CTRL-WCTRL-W to go back to the left pane

Then, you can go through yanking the words you want, so for each word:

  1. /word1 to go to it
  2. yiw to yank that word into the unnamed register
  3. CTRL-WCTRL-W to go the right pane
  4. p to paste from the unnamed register
  5. CTRL-WCTRL-W to go back to the left pane

As @Rich notes in the comments, you can record a macro to do steps 2-5. For example, to record to the b register you would use qbyiwCTRL-WCTRL-WG:putCTRL-WCTRL-Wq. You can then go to the next word with /word2 and execute the macro with @b. Note that I've used :put in that macro rather than p as this puts the yanked text on a new line, which I suspect is what you want.

More information: :h windows.txt and :h complex-repeat

Option 2: jumps

If you press G to go to the bottom of the document, you can then press CTRL-O to go back to where you were previously. You can then adopt a strategy similar to above.

More information: :h jump-motions

Option 3: marks

More generally, if you want to remember where you are in a document, go elsewhere to do something (e.g. the bottom of the document to paste something) and then return to a certain place, you can also use marks. In this setting, you might use ma to set mark a, navigate away to do something, then return to that place with `a.

More information: :h mark-motions

Option 4: appending to a register

This can be used in combination with any of the above movement strategies. When you yank a word with yiw, you are actually yanking to the unnamed register. This is the equivalent of ""yiw. You can yank to a named register such as a with "ayiw.

If you want to append rather than replace the content of a register, you can use the uppercase version of that register. So, for example, a workflow might look like this:

  1. /word1 to go to a word you want to yank
  2. "ayiw to yank that word into the a register
  3. /word2 to go to another word to yank
  4. "Ayiw to append that word to the a register
  5. repeat for more words...
  6. Then, when you are ready, go to the bottom of the document with G and paste the a register with "ap.

If there is already something in that named register, you can effectively clear it with qaq.

If you use this strategy, you may want to also add > to cpoptions (using :set cpoptions+=> which puts a linebreak before appending text to that register.

More information: :h registers and :h cpoptions.

Option 5: :global

If you know a unique regex that encompasses the line(s) that you want to yank then the :global command can be used.

For example, if you want to yank all lines containing the regex foo to register c, use:

:global/foo/yank C

This can be abbreviated to :g/foo/y C. Note that this is the ex command :yank, not the normal mode mapping y. :yank yanks the whole line to register c.

To yank less than a line, use a normal mode as the command to :global like so:

:global/foo/normal "Cyiw

If doing so, it's likely that you'll want to add > to cpoptions as above.

  • If I find myself using your option one for anything more than about 5 occurrences, I'll usually record a macro to automate steps 2-5 so they can be done with a couple of keypresses.
    – Rich
    Mar 12, 2021 at 22:45
  • Also, +1 for cpo->; I learned something new today!
    – Rich
    Mar 12, 2021 at 22:47
  • @Rich Good idea for the macro, I've added some information on that. Mar 13, 2021 at 0:07
  • My personal favorites include :global/…/ where the command is either :to in the case of whole lines or :normal with some yanking sequence into a capital register (to append, as you said)
    – D. Ben Knoble
    Mar 13, 2021 at 3:57
  • Thanks @D.BenKnoble I've added a bit about :global. What is :to? :h :to just takes me to :topleft. Mar 13, 2021 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.