gVim is a powerful editor that makes a lot of editing work a piece of cake. Here’s a cheat sheet that can help you get the most off this editor. For those who would like to get the work done without using a mouse, it may be the perfect editor. This cheat sheet is geared towards beginners who use editors a lot, perhaps programmers, and will like an easy introduction.

First, for those from a Windows background, there are 3 modes of working in gVim, command mode, insert mode, and visual mode. On opening gVim, you start off in command mode. To type in text, you must go to insert mode. To select text by highlighting, as you do in Windows, you go to visual mode. Without further ado, to the commands.

Opening, saving, moving between files, and closing files

  • e c:\path\to\your\file  – opens the file, or creates one at that path file doesn’t exist. If you use this on a directory, it opens the directory while showing error message on command bar
  • tabnew c:\path\to\file – opens (creates) file at specified path in a new tab
  • w – save file
  • sav c:\path\to\file – save file as the name given
  • q – close file
  • wq – save file and close it
  • q! – close file without saving (gVim normally issues an error if you try ‘q’ without saving last changes)
  • ctrl pg up – go to previous tab
  • ctrl pg dn – go to next tab

Switching between differnt modes

Switching from command to insert mode

  • i – places the cursor behind it’s current position.
  • a – places cursor after current position

Switching from insert to command mode or from visual mode to command mode

  • esc

Switching from command to visual mode

  • v – to selct text
  • shift+v  – to select line

Moving around documents

  • k – moves up a line
  • j  – moves down a line
  • h – moves left on current line
  • l – moves right on current line
  • w – moving to beginning of words in forward direction
  • e – move to end of words in forward direction
  • b – move to beginning of words in backwards direction
  • gg – move to first line of file
  • G – move to last line of file. Same with :$
  • ^ – move to beginning of line
  • $ – move to end of line.
  • :## – move to line ##

Moving accross screen

  • pg up – moves to previous screen
  • pg dn – moves to next screen

Copying and pasting

  • yy – copies (yanks) current line
  • 3y – this example with yank 3 lines starting from current line
  • P – paste copied text before cursor
  • p  – paste copied text after cursor.
  • “+y – copies to clipboard (making content available to other apps)
  • “+gP – pastes from clipboard. eg from your web browser into gVim

Inserting and Replacing text

  • O – creates(opens) a blank line before cursor and goes to insert mode
  • o – creates(opens) a blank line after cursor and goes to insert mode
  • ggVG – select everthing in current document
  • cw – change current word (deletes current word and puts you in insert mode)
  • ci{ – deletes everything within the nearest matching braces and puts you in insert mode. eg. if you had a function – function x(){ /* old st */ } and you want to quickly change the entire implementation of that function, you move your cursor into that {} and use ci{. Note: ci} accomplishes same task.


  • dd – cuts current line into gVim’s clipboard (making content available only within gVim for paste)
  • 3d – example that deletes 3 lines starting from current line


  • shift v > – adds indent on current line
  • shift v < – removes one indent from current line

Copy and Paste between gVim and other applications

  • “+y – copies to clipboard
  • “+gP – pastes from clipboard

Searching and Replacing

  • /searchpattern – searches for text with patter ‘searchpatter’
  • rs/searchpattern/replacepattern/o – this does a search and replace where r and s are options of various values. r can be nothing, in which case only current line is searched, % – in which case whole file is searched, a-b (where a and b are line numbers) in which case the range defined by a and b are worked on.   o stands for a series of one or more options (g, c, i,l). g- means all occurrences on lines are worked on. c- means you are asked for confirmation before each replace. i- case insensitive search, l-case sensivitive search

That’s all for now.  Happy gViming.