kernel_os
kernel_os

Reputation: 129

searching in vim editor

this is a simple query about the searching in vim editor.

consider that i searched for a string like "str" with

/str

now after this search i wanted to search for "strcat" like

/strcat

but, the point in here is that i dont want to type entire /str again.... just wanted to add the new text to /str. that is when we made the first search we type /str and for the second search i just wanted to type cat for searching the entire /strcat.

can any of you vi guru's tell me if it is possible for us to do some search like this in vi.

thanks in advance

Upvotes: 2

Views: 215

Answers (3)

William Pursell
William Pursell

Reputation: 212148

Besides up-arrow to get the previous search, you can also do /^f to be able to fully edit many previous searches. (That's / followed by Ctrl+F). Put the cursor on the previous search that you want to edit, edit it, and hit return.

Upvotes: 7

Curt Nelson
Curt Nelson

Reputation: 3192

Others have answered the question you asked, but on the off chance that incremental search would better suit your workflow, I thought I would mention it.

If you're only searching once and finding out that what you're searching for is not unique enough and you need to add more characters, incremental search will show you that before you press enter.

Put the following in your .vimrc to enable incremental search:

set incsearch

Upvotes: 0

Andy Finkenstadt
Andy Finkenstadt

Reputation: 3587

The / key begins a search string. up arrow recalls the previous line(s). Therefore,

/ up-arrow cat

will resume your search.

Upvotes: 8

Related Questions