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


Comments

Leave a Reply

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.

Enable Notifications OK No thanks

We use cookies - more information

Multimusen.dk will set a few cookies from Doubleclick, Google and the Social Media plugins they ay set some cookies. Some of my pages use APIs - such as YouTube, LinkedIn, Google Fonts, Google Maps, Mapbox, Spotify, Jetpack, Twitter, Facebook &c.. Such plugins may set the odd cookie.

Close