Thursday, November 17, 2011

Useful GVIM Tips

The things that I didn't know about GVIM editor.

How to prepare _vimrc file (i.e. the file with the default settings)

1. Copy "C:\Program Files (x86)\Vim\_vimrc" to $HOME/_vimrc.
If you don't have $HOME variable, you may see it in Gvim with the help
:e $HOME/_vimrc

2. Edit $HOME/_vimrc, add commands there.

vim $HOME/.vimrc
add commands there.

For instance, my favorite tab stop options:
:set tabstop=2
:set shiftwidth=2
:set expandtab
:set backspace=indent,eol,start

How to make the 'Backsapce' key work properly in Edit mode:
:set backspace=indent,eol,start
(more info here:

How to start Gvim maximized under Windows:
(taken from
Add the following line to _vimrc:
au GUIEnter * simalt ~x "x on an English Windows version. n on a French one

It is possible to have only one Gvim running:

Edit "file.txt" in server "FILES" if it exists, become server "FILES"
    gvim --servername FILES --remote-silent file.txt

This means that you'll have only one Gvim running. New files will be opened in already running Gvim.

More information here:

Hidden characters in GVIM

Display hidden characters: :set invlist
(taken from 

Learn the code of symbol under the cursor: ga

Find the symbol with code (for instance, Tab symbol with hex code 09):
Replace: the same, for instance :s/\%x09/  /gc
(taken from

How to show line numbers:
To turn line numbers on  :set nu
To turn line numbers off :set nu!  

How to convert the file from Windows to Unix format using GVIM
(i.e. replace \r\n to just \n)
1. Open file in GVIM.
2. :set ff=unix
3. Save the file and exit

How to remove empty lines in GVIM

(more tips here:, great source of GVIM info) 

How to make arrow keys work properly in edit mode in Vi on Linux term

Problem: It seems that when I am using VI through putty when I am in insert mode I get escape characters, instead of the cursor moving when I use the arrow keys.

Solution: 1. use vim.
2. Create a .vimrc file in your home directory:
echo syntax enable > ~/.vimrc

Read here:

To be continued...

No comments:

Post a Comment