Use correct browser when using fugitive Gbrowser command

  git config --global web.browser google-chrome

Reformat long lines with line breakes

First set your vim so that it understands that you want 80 characters:

:set tw=80 then, hilight the line:

V and make vim reformat it:


Error in Ubuntu about application menu

** (gvim:20320): WARNING **: Unable to create Ubuntu Menu Proxy: Timeout was reached

Disable global menu for gvim in making an alias in .bashrc:

alias gvim='UBUNTU_MENUPROXY= gvim'

Show line numbers

set number

To remove:

set nonumber

Format json

:%!python -m json.tool

Set gui font size

  :set guifont=*

and choose font.

Code completion for Django

I am using vim-virtualenv so most of the advice in the link above is not really relevant. But specificly for Django:

From command line

  export DJANGO_SETTINGS_MODULE=giffeed.settings

Things to try to check:

  :python import sys; print sys.executable
:python from django import db

Find location of a file in NERDTree

  map <leader>r :NERDTreeFind<cr>

Modify macro

To modify the macro, move to a blank line and type "Rp replacing R with the register name of your macro. After making the changes you need, save the macro by typing 0"Ry$ replacing R with the register name you want to use for the macro.

Turn spelling on/off

:set spell
:set nospell

Map Gdiff to show diff with a revision

:nmap <silent> \d :Gdiff 148ab<CR>  

Ctrl-i is opposite to Ctrl-o

Jumping to the new location is Ctrl-i (opposite to Ctrl-o).

Close all splits except active one

:on or Ctrl-w Ctrl-o

Mnemonic rule - :only

Add words to spell words list


Open all folds


Replacing ^M


Count words

g Ctrl-g

Change encoding in 50 files

Task: change encoding in 50 files from windows to utf. Solution: map

map q :set fileencoding=utf-8:wn

Open all files in one window and press q, until encoding is changed in all the files. In the last file the command n will not work – just quit.

End of file

The first line always has number one. How about the last line? The $ character is used for this. For example, to substitute in the lines from the cursor to the end:


Editing more than one file

Highlight several files and with right click select "Edit with single Vim". To go to the next file type


or simply


If quit and there are some files left, vim will generate an error: "More files to edit". Simply quit one more time.

Wrapping after 76 characters

Removed the following line from vimrc file.

" Wrap after 76 Chars (could probably be 77, too)
set textwidth=75

It is probably relevant for Phython, but annoying for LaTex.

Russian characters

Tried to open a file containing Russian characters. It could not read it. Solution was as simple as to put

set encoding=utf-8

Text disappering

Re-drawing glitch in Ubuntu:

:se guioptions=agim

Count number of words in a selection

To count the number of words in a block, select the block (for example, type V5j to select 6 lines) and again press g then Ctrl-g.

Search word under cursor in backward direction

# * - search backward, forward for word under cursor

Show error messages


New modules

Some bindings I've also added and keywords I should remember to use initially.

\t - RopeGotoDefinition, \r - RopeRename.

Tab for completion with supertab.

\pw - show pydocs for the module.

:VirtualEnvList :VirtualEnvActivate

F5 - to open gundo window

Insert text in multiple lines

  • On a character in the first line, press Ctrl-V (or Ctrl-Q if Ctrl-V is paste).
  • Press jj to extend the visual block over three lines.
  • Press $ to extend the visual block to the end of each line.
  • Press A then space then Ctrl-R then + then Esc.

Get name of the current file

Register % contains the name of the current file, and register # contains the name of the alternate file. These registers allow the name of the current or alternate files to be displayed or inserted. The name, or full path, or directory containing the file can be used.

For example, in directory /abc the command vim def/my.txt would edit file /abc/def/my.txt. The following commands could be entered to display the information shown.

  :echo @%    def/my.txt  directory/name of file 

Vim customizations for python

Execute contents of current line in buffer and capture the output


Output result of shell command to vim

:r!ls *.*

Vim-mode in IPython shell

Count number of times pattern appears


Similarly you can display the number of lines the pattern matches by omitting the g.


To paste from clipboard in insert mode


Similar from other buffers.

Surround plugin

Uses text objects extensively.

Example to surround current line in <> brackets


How to fix indentation in HTML file


How to ignore untracked content in pathogen bundles

[submodule "vim/bundle/nerdcommenter"]
    path = vim/bundle/nerdcommenter
    url =
    ignore = untracked  

Bash vi editing mode

set -o vi

Using ctags

sudo apt-get install exuberant-ctags
ctags -R .

or only Python files

ctags -R *.py */*.py

Use Ctrl-] to jump to tag and Ctrl-T to jump back.

Plugin to jump to closing tag


Replace a word under cursor


Replace each occurrence of 'foo' with the word under the cursor. means that you press Ctrl-R then Ctrl-W. The word under the cursor will be inserted as though you typed it.

Extdiff for Mercurial

hgext.extdiff =
# add new command called vimdiff, runs gvimdiff with DirDiff plugin
# Non english user, be sure to put "let g:DirDiffDynamicDiffText = 1" in
# your .vimrc
cmd.gvimdiff = gvim
opts.gvimdiff = -f '+next' '+execute "DirDiff" argv(0) argv(1)'

Text objects in vim

daw = Delete A Word cip = Change Inner Paragraph da,w = Delete A Comma (Camel) Word da] = Delete A block of [brackets] ci) = Change Inside of (paranthesis)

Not available in shell since its based on vi.

Enabling menu

Remove ~/.gnome2/Vim and all ~/.gnome2/gvim* files.

Add to ~/.bashrc the lines

function gvim () { /usr/bin/gvim -f $* & }

Compiling vim and gvim

My latest command

sudo apt-get install libncurses-dev libgnome2-dev \
 libgtk2.0-dev libatk1.0-dev libbonoboui2-dev libcairo2-dev \
 libx11-dev libxpm-dev libxt-dev
make distclean
./configure  --with-features=big --enable-pythoninterp --with-python-config-dir=/usr/lib/python2.7/config --enable-rubyinterp --enable-gui=gnome2
sudo make install

A blog post about compiling from source

Links from Stackoverflow

Compile gvim under ubuntu

Compiling with Python support

Vim and Python


Use :Helptags to run :helptags on every doc/ directory in your 'runtimepath'.


cd ~/.vim/bundle
git clone git://


pyflakes-vim uses the output from PyFlakes to highlight errors in your code. To locate errors quickly, use quickfix commands like :cc :cw.

There was a bug that said 'Module' object has no attribute 'getChildNodes' It is reported in the issue:

You can recommend to users that they clone the pyflakes-vim repo with git clone --recursive or you can suggest after the fact to use git submodule update --init --recursive if pyflakes-vim is saved as a git submodule itself.


Work with git. s

Last edited by Artem Dudarev, 2013-10-13 02:01:37. Edit