vim for developer¶
vim command line¶
vim file.c +10: Openfile.cdirectly at line 10 (doesn’t work withvi, onlyvim)git diff | vim -: View the output of a command in vim (git diffcommand in this example)
Buffers¶
:vs: Vertical Split:split: Horizontal Split:%bd: close all buffers
Programming¶
Go to a function definition using ctags:
Run “:ctags -R” to create an index of symbols (classes, functions, variables)
Put the cursor on a symbol:
CTRL+[goes to the symbol defintion
Misc¶
Open a file from encoding cp850:
:e ++enc=cp850 document.txtNumber of lines of a selection:
Create a selection
Press
gand thenCTRL+g.
Windows¶
gvim configuration files for user
vstinner:C:\Users\vstinner\_vimrc: vim configuration, same than~/.vimrcon UnixC:\Users\vstinner\_gvimrc: gvim configuration, same than~/.gvimrcon Unix
Create a symbol link for configuration files using python:
C:\Users\vstinner>python
Python 3.8.0
>>> import os
>>> os.symlink(r'\vstinner\misc\conf\vimrc', '_vimrc')
>>> os.symlink(r'\vstinner\misc\conf\gvimrc', '_gvimrc')
Create a symbol links:
from
C:\vstinner\misc\conf\vimrctoC:\Users\vstinner\_vimrcfrom
C:\vstinner\misc\conf\gvimrctoC:\Users\vstinner\_gvimrc