Vi – cheat sheet

the vi editor
Vi with line numbers, dark background and colored syntax in a markup environment.

Vi is a very powerfull editor, that is … for the initiated. Here are some of my favorite vi commands:

Colors, syntax, write, quit

  • :syn on – colored syntax
  • :syn off – no colored syntax
  • :set number – line numbers
  • :set background=dark – better color contrast in a dark terminal window
  • :q! – quit without saving
  • :w – save
  • :wq – save and quit

Copy / Paste

First mark some text. Move the cursor to the beginning of whatever should be copied. Then press v. Now you can mark something. Press Y to yank or d to delete (= cut). Move the cursor to where you want to put the clipping or copy. Then press p.

Save Your Favorite Settings

You may want to save your favorite settings. Vi use the file .vimrc – my .vimrc looks like this:

set number
set background=dark
syn on
set autoindent
set shiftwidth=4

Published by Per Thykjaer Jensen

Senior Lecturer at the Multimedia Design and Communication Programme at Aarhus Business College. I teach code and UX. Linux evangelist and WordPress expert.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.