开发者

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


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

/ up-arrow cat

will resume your search.


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.


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜