Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there any way to use regular expression for movement in vim. For example, I want to move my cursor to the first occurrence of the pattern abc. So can I do something analogous to fa but now a character replaced by a pattern? And can I use regular expressions with t and f command?

share|improve this question
1  
You can search with regex and the cursor will move to the start of the regex. Is this what you mean? –  Sardathrion Aug 20 '12 at 7:10

1 Answer 1

As stated in a comment by Sardathrion, you can search to navigate. This is actually too useful in Vim to ignore. A few tips regarding search to navigate:

  • Use / to search forward, ? to search backward.
  • You may want to turn on incsearch so that Vim will jump to matches as you type. Hit Enter when you are at the location you want.
  • You may also want to turn on search highlight with hlsearch.
  • After arriving at the location you want, you can use nohlsearch to disable the highlight. It will be enabled again when you do the next search.
  • If you find yourself using lots of regex consider using \v ("very magic").
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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