In vim, how do I go back to where I was before a search?
Programming in vim I often go search for something, yank it, then go back to where I was, insert it, modify it.
The problem is that after I search and find, I need to MANUALLY find my way back to where I was.
Is there an automatic way to go back to where I was when I initiated my last search?
Ctrl+O takes me to the previous location. Don't know about location before the search.
Edit: Also, `. will take you to the last change you made.
在搜索/跳跃之前,使用``
跳回到您所处的确切位置,或者''
跳回到您搜索/跳转之前所在行的起始位置。
I've always done by it setting a mark.
In command-mode, press m [letter] . For example, ma sets a mark at the current line using a as the mark indentifier.
To get back to the mark press ' [letter] . For example, ' a takes you back to the mark set in step 1.
To see all of the marks that currently set, type :marks .
On a slightly unrelated note, I just discovered another nifty thing about marks.
Let's say you jump to mark b by doing 'b . Vim automatically sets the mark ' (that's a single-quote) to be whichever line you were on before jumping to mark b.
That means you can do 'b to jump to that mark, then do '' (2 single-quotes) to jump back to whever you were before.
I discovered this accidentally using the :marks command, which shows a list of all marks.
链接地址: http://www.djcxy.com/p/8684.html上一篇: 你如何让vim不重视你搜索的内容?
下一篇: 在vim中,我如何回到搜索前的位置?