DEV Community

Moving around in Vim

Igor Irianto on October 17, 2019

Follow @learnvim for more Vim tips and tricks! Being able to freely move around in a file is an indispensable vim skill. Below is a list of the ...
Collapse
 
fidelve profile image
FidelVe

One I use quite often is:

:!<command>

This will run a shell command, show you the result and then go back to vim, is pretty useful when you need to run a shell command without opening another shell window or closing vim

Collapse
 
miniscruff profile image
miniscruff

Ohh yes and using % will insert your open buffer file.
:!black % will run python black on your open file

Collapse
 
iggredible profile image
Igor Irianto • Edited

Haha yup! I actually made a note to dig into this. This command alone unlock myriads of possibilities.

Going off topic- something I learned these past 3-4 weeks thought I would share!

  • :!! repeat the last :!command :)
  • :r prints output into vim - :r !ls for example, prints the output of ls command - I am sure will come in super handy!
Thread Thread
 
miniscruff profile image
miniscruff

Oh yea always forget !!.
I also gotta learn the other special characters I think # means something as well.

Collapse
 
miniscruff profile image
miniscruff • Edited

Two of my favorites
q/ show your history of searches
q: show your history of commands

Collapse
 
bakadesu profile image
バカです • Edited

Can you explain?

code:/ ? :q ?

What did you mean?

Collapse
 
miniscruff profile image
miniscruff

Sorry it is actually...
q/ for search history.

Press those keys to get a buffer that shows your history of commands or searches

Collapse
 
codenutt profile image
Jared

Awesome list. Thank you!

Collapse
 
iggredible profile image
Igor Irianto

Hope it helps!! 😁