Vi Helpful Commands

Figured I’d write down a quick set of commands in VI. Also, I keep on forgetting a few useful commands in vi so I’m gonna start archiving them here.

Show Hidden Characters

:set list

Reload a file from disk


Hide Hidden Characters

:set nolist

Fix vi’s broken arrow keys (mostly ubuntu machines)

:set nocompatible

Or better yet put it in the .vimrc file.

 echo “set nocompatible” >> ~/.vimrc

Change blue syntax coloring to something you can read on black backgrounds

Add “hi comment ctermfg=blue” to the .vimrc file

 echo “hi comment ctermfg=blue” >> ~/.vimrc

Navigate to top and bottom

Go to top:


Go to bottom:



Search up:


where <SEARCHSTRING> is what you’re looking for.

Search down:


Ignore caps in search:




 Editing (Insert mode)


Press ‘esc’ to get out of insert mode. Use arrow keys and page up/page down to get around.

Delete current line


Delete from one marker to the next

First make a marker


Where k could be anything from the letter ‘a’ to ‘z’

Now move your cursor somewhere and type


This will delete everything between your current cursor and the marker at k.

Also note that typing k will take you to that marker.

Exit and don’t save


! means force. If you changed something and didn’t put !, then it wouldn’t let you exit.

Exit and save


Open a file in read only mode



Find and Replace


The above does one line on the cursor, but to do the whole page