VIM: combine two requests

Often I search for something (using hot keys, a menu command or command line), and after that I want to save the first search and add another search.

pe
- First, I look at the spaces in my text.
- Then I want to keep matches and add a search at all ends of the spaces

Is there a way to combine 2 search queries?

1) search 1
2) press F9 or another key: ADD
3) search 2

+3
source share
3 answers

You can do it:

exe '/\('.histget('/',-1).'\)\|\('.newSearch.'\)'

where newSearch is your new search string. A good way to do this is to simply search separately to make sure you get what you want and then combine them with:

exe '/\('.histget('/',-1).'\)\|\('.histget('/',-2).'\)'

, , .

, , ( ). , , .

+2

Esc, \, Up-Arrow, , . , Up-Arrow .

_pipe(, : Esc /_pipe(

, , _pipe(, , option, : Esc / Up-Arrow

, /_pipe(.*option.*)

, .

+2

In normal mode, you can use the last search register ( "/) to call the last search pattern:

/<C-r>/\|\(\[ ]\+$\)

Destruction:

  • <C-r>yes CTRL + r, it will print a "so that you can choose a register,
  • /to select a search register,
  • \|add another template to your search ( OR),
  • \(\[ ]\+$\) Search and group trailing spaces.
+2
source

All Articles