Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the 'f' command in vim to search more than just the current line

Tags:

vim

I know that philosophically the f/F command is used to search through the current line. However, other than [LINE]G f, what would be the best way to jump to somewhere else in the file in the style of the f command?


2 Answers

Add this line to you ~/.vimrc

set incsearch

to activate incremental search and use /foo<CR> to search forward or ?bar<CR> to search backward.

Note that, like fFtT, /? can also be very useful as motions for dcsv.

If you don't mind using a plugin, there are a bunch of them designed around the idea of multi-dimensional fFtT like this one. Take a look around vim.org.

like image 101
romainl Avatar answered Sep 07 '25 16:09

romainl


You may want to use the vim plugin EasyMotion,

  • github repo
  • vim online

<Leader>f<char> will search forward from current line to the end of current window. <Leader>F<char> will search backward from current line to the start of current window.

for all usage :help easymotion.txt

like image 38
swpd Avatar answered Sep 07 '25 17:09

swpd