vim for developer¶
vim command line¶
vim file.c +10
: Openfile.c
directly at line 10 (doesn’t work withvi
, onlyvim
)git diff | vim -
: View the output of a command in vim (git diff
command 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.txt
Windows¶
- gvim configuration files for user
vstinner
:C:\Users\vstinner\_vimrc
: vim configuration, same than~/.vimrc
on UnixC:\Users\vstinner\_gvimrc
: gvim configuration, same than~/.gvimrc
on 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\vimrc
toC:\Users\vstinner\_vimrc
- from
C:\vstinner\misc\conf\gvimrc
toC:\Users\vstinner\_gvimrc