VIM Super Fast Navigation

The only thing I miss about using other editors is to find my place with the mouse. I can look with my own eyes at a certain area in the file and with the movement of the mouse and with one click of the mouse. With vim i have to jjjjjjkkkkkkjjjhhhh ... almost there hhhhh oh shit I missed 3 characters, lll.

I'm learning to make notes, and I found a bookmark plugin that is different, I can create markers and destroy them with <f3> and navigate to them, unfortunately the tags are forgotten when the file is closed.

How do you all super browse files? I know that I could also do 5j7k4j5h etc., but there should be a plugin that can read my eyes and place the cursor where I really need it.

I also learned to use /% to search for a specific term. This helps, but all relevant characters are highlighted from the document.

+56
vim navigation
Jan 05 2018-12-12T00:
source share
9 answers

Try $ vimtutor , it will teach you everything you need to know to get started.

hjkl are the tip of the iceberg and are very rarely used, at least in my case.

wWEe and BbgegE all allow you to navigate a word:

  • w and e go ahead, w and e consider spaces and punctuation

     " here the * marks the default location of the cursor " and each letter shows where you jump when you hit the key. Latin: Lorem ipsum dolor sit amet. * eee * EEE * wwwwwww * WWWWWW 
  • b and ge go backward; b and ge consider spaces and punctuation

     Latin: Lorem ipsum dolor sit amet. bbbb * BBB * ge ge ge* ge gE gE gE* 

fFtT are used to achieve a certain character on the current line and fFtT are used to repeat this movement in the same direction for ; and in the opposite direction for:

  • fm goes next m forward, F goes back

     Latin: Lorem ipsum dolor sit amet. * fm ; ; ; Fm * 
  • tm goes to the next m forward, T goes back

     Latin: Lorem ipsum dolor sit amet. * tm ; ; ; Tm * 

/? used to go to the first occurrence of the template from the current cursor position:

  • /pattern goes forward

     Latin: Lorem ipsum dolor sit amet. * /ips 
  • ?pattern goes back

     Latin: Lorem ipsum dolor sit amet. ?Lat * 

0$ are used to go to the first and last character of the string.

  (whitespace)Latin: Lorem ipsum dolor sit amet.(whitespace) 0 * $ 

^g_ are used to jump to the first and last printable character of a string.

  (whitespace)Latin: Lorem ipsum dolor sit amet.(whitespace) ^ * g_ 

Single and combined ()[]{} are used to move a phrase across a phrase or paragraph or code by a block of code.

<Cb> and <Cf> are used to scroll back and forth across the screen.

<Cu> and <Cd> are used to scroll half-screen back and forth.

H , m and L move the cursor to the top, middle, and bottom of the viewport, respectively.

zt , zz and zb move the line under the cursor to the upper, middle, lower parts of the viewport, respectively.

And so on.

:help motion.txt will hit your mind.

+87
Jan 6 2018-12-12T00:
source share

Besides the vim motion command, I find the vim plugin named EasyMotion to be quite useful to navigate if you are familiar with vimperator or pentadactyl, EasyMotion will simply return the hint mode back to vim. here is an animated demo and here is a video tutorial. Hope it will be helpful for you.

+20
Jan 06 '12 at 1:23
source share

There are two million ways to travel in vim, this is one of its really strong areas. I use a lot of { and } , which move up and down to the next empty line in that direction. % is useful for moving back and forth into a suitable bracket (of any type). W and B move forward and backward in the word.

It might be worth considering the Moving section of the Vim manual.

+16
Jan 05 2018-12-12T00:
source share

Vim has mouse support! try (in your .vimrc):

 set mouse=a 

sidenote : as a screen user, I found that I also need

 set ttymouse=xterm2 

for this.

+8
Jan 05 2018-12-12T00:
source share

I personally prefer to use:

 "/<chars><enter>" to quickly move to somewhere ( extremely fast! trust me! ) ":<number>" to go to some line, "ctrl + f/b" to forward/back "g;" to move to the last editing place. "w/b" to move by word "jklh" to move your cursor to the exact position 
+5
Feb 24 '14 at 5:48
source share

With the relativenumber option ( : help relativenumber - bundled with Vim 7.3 ), you can get to the line under the eyes with [count]k or [count]j , which you can move in the current line with movements such as ftweb , as explained by @ romainl.

+3
Jan 6 2018-12-12T00:
source share

In addition to { , } , ( , ) , <number>cb , <number>cb , <number>cW and % , I use the following navigation methods:

  • ciw , diw ( ciw , diw ). etc. to quickly edit / delete a word under the cursor (including characters without a space).
  • ci( , ci" ( ca( , ca" ), etc., to quickly edit inside parentheses, quotes (including parentheses, quotation marks). The same goes for d .
  • Signs with CAPITAL letters to set them globally (via files) and persistently (when the buffer is closed). For example, mA will create a global label A , which will be accessible using the 'A (or `A to evaluate a column) command.
  • gf quickly jump to file under cursor
  • f , t ( f , t ) to go to char, before char to the right (left) (use ; to repeat). They are especially useful for d and c commands (use . To replay).
  • ^] to go to the tag and ^T to go back.

And many other ways to move :)

Check this out for more information: http://www.thegeekstuff.com/2009/03/8-essential-vim-editor-navigation-fundamentals/

PS For rails users there is a very useful rails-vim plugin, you can also check it.

+3
Jun 16 '13 at 9:42 on
source share

this is a good place to learn the basic navigation commands, part of the power / speed vim comes from a combination of movement with action i.e. cw change word, d10j - d10j delete 10 lines down, etc. Also this and this are interesting readings.

+2
Jan 05 2018-12-12T00:
source share

You can :set nohlsearch turn off the highlighting of your search characters.

I also use ctags.

+2
Jan 05 '12 at 22:15
source share



All Articles