My dot files for vim and git
I prefer tools which can be used with terminal, so install vim from source is the perfect way for me, and it's also the reason why I don't use MacVim.
-
Get a copy of source code from https://vim.googlecode.com/hg/, before that please make sure you have "hg" installed
$> hg clone https://vim.googlecode.com/hg/
-
Installation with huge set of features
$> ./configure --prefix={dir\_to\_install} --with-features=huge --enable-rubyinterp --enable-pythoninterp --enable-python3interp --enable-perlinterp --enable-cscope $> make $> make install
There is a shell script which you can use to finish the installation of vim plugins
in this repository and you can find it here vim/install.sh
Notice: in this repository I use ,
as leader key, so don't be suprised when you see
a lot of ,
in the hot key of the following usage example
-
Text Search
Tools: Ag https://github.com/rking/ag.vim
Usage:
, + a
search text under the current workspace
, + s
search the current word where the cursor is for python files -
File Search
Tools:
ctrp https://github.com/kien/ctrlp.vim
personaly I like ctrp more than command-t, ctrp is better than command-t in performance and search result Usage:
Ctrl + p
fuzz search for files by name
Ctrl + c
quit ctrlp -
File Navigation
Tools:
NerdTree https://github.com/scrooloose/nerdtree
Minbuff https://github.com/fholgado/minibufexpl.vim
Usage:
, + t
open NerdTree sidebar
, + f
open NerdTree sidebar and find the current file's location
b + number
switch from different file from mimbuff -
Code Exploring
Tools:
ropevim https://github.com/python-rope/ropevim
tlib https://github.com/tomtom/tlib_vim
tagbar https://github.com/majutsushi/tagbar
Usage:
, + g
following python code's definition
Ctrl + o
back to the last cursor position during code exploring
Ctrl + t
move forward to the last cursor position during code exploring
f3
Open/Close right sidebar for code structure -
Code Completion
Tools: ropevim
Usage:
Code completion have to be under insert mode and by using rope you could apply completion
in python code
Ctrl + x Ctrl + o
active auto completion for python code
Ctrl + n
active auto completion for any code (not very intelligence) -
Status Line
Tools:
ariline https://github.com/bling/vim-airline
fancy status line tools which can show file type, cursor coordinates, encode type and etc -
Code Snippets
Tools:
vim-snippets https://github.com/honza/vim-snippets
Usage:
when you type some keyword following with tab you can automatically bring out the code snippets
for example if you type ifmain and then following with a tab in a python file it will bring out the following codeif __name__ == '__main__': main()
type pdb with a following tab
import pdb; pdb.set_trace()
there are a lot other hot keys which are quite useful accross different lanuages and most
importantly you could be very productive -
YAML
Tools:
vim-yaml https://github.com/stephpy/vim-yaml
vim's built-in YAML support is almost useless, it's super slow so this plugin can make a difference
Install formatters could let you unlock auto formatting your code with hot key + r
npm install -g prettier
# sort python imports
pip install isort
# python code formatter
pip install black
f7
Copy current file path to system registerf2
Open/Close preview windowCtrl + h
move cusor to the left windowCtrl + l
move cusor to the right windowCtrl + i
move cusor to the window upsideCtrl + k
move cusor to the window downside:vsp
split window verticallyCtrl + z
bring vim process to backgroundfg
bring back background process this is a terminal command will be useful withCtrl + z
!command_line %
execute command line
for example use:!git blame %
to blame the current file with git- shared register with system register
this means the text you copy from vim can been pasted to other program and the oppsite is also true :qa
quit vim
-
Configure press and hold
defaults write com.jetbrains.intellij ApplePressAndHoldEnabled -bool false
defaults write com.jetbrains.intellij.ce ApplePressAndHoldEnabled -bool false