GVim tips and tricks

This largely relates to getting GVim set up on the beautiful Windows operating system.

* vimrc file on Wikia: http://vim.wikia.com/wiki/Open_vimrc_file * Setting the .vimrc file on windows: http://stackoverflow.com/questions/9120500/vim-settings-file-on-windows * Setting up GVim on windows * NVAlt mode for GVIM - there's a plugin called nvim here https://github.com/cwoac/nvim * How do I get VIM home directory * VIM introduction and tutorial


Between files

Open demo files, enter:

  $ vi /tmp/foo /tmp/bar


  $ vi /tmp/{foo,bar}

To list open files:


Sample outputs:

 1 %a   "/tmp/foo"                     line 1
 2      "/tmp/bar"                     line 0

To switch to next file:




To switch to previous file:




To open specific file buffer called 10 (use :ls command to list all open file buffers):


You can also switch between all open files, using the following syntax:

  :b foo


  :b bar

Modern text editor such as vim supports enhanced tab completion to get list of open file:

  :b [HIT-TAB-KEY]

To save currently open file:


Visual editor

To split the current window vertically:

  CTRL+W v

To split the current window horizontally:

  CTRL-W s

To switch between vertically open windows i.e. navigate through open windows:

  CTRL-W h


  CTRL-W l

To switch between horizontally open windows i.e. navigate through open windows:

  CTRL-W k


  CTRL-W j

Once switched you can load file using any one of syntax as discussed above:


Templates and scripts

Changing fonts in the editor

From Stackoverflow

In $MYVIMRC, add the line:

  set guifont=DejaVu\ Sans\ Mono:h11

…where :h11, specifies a height of 11 points.

Internal file linking like in the GVim help

From http://vim.wikia.com/wiki/Keep_a_to-do_memo_file_with_links_as_in_Vim_help

  • memo.txt* My Memo - extending my poor memory |guide|
  1. —————————————————————
  • subjects* *toc*

|cmd| command tips |def| definitions

  |dev| developments |ed| editors |friends| friends
  |lang| languages |misc| others
  |private| personal info |sys| system
  Commands *cmd*
  |doskey| DOS key utility
  <F8>: expand history
  |man| Unix manual
  man foo
  nroff -man foo.1 | less
  nroff -man foo.1 | a2ps -m
  Development *develop* *dev*

Vim needs to have the following tag file to go to where you want it to go:

  %userprofile% memo.txt /*%userprofile%*
  .htaccess meo.txt /*.htaccess*
  access memo.txt /*access*
  access.conf memo.txt /*access.conf*
  addressbook memo.txt /*addressbook*
  anchor_keyword memo.txt /*anchor_keyword*
  apache memo.txt /*apache*
  as index.txt /*as*
  at index.txt /*at*
  awk index.txt /*awk*

Tags in Vim

Turning Vim into an IDE, using Tags as index: http://peterodding.com/code/vim/easytags/