This is my vim configuration.
git clone --recurse-submodules git@github.com:zhonglin-xu.vimrc.git
sh ./install.sh
Use git for windows to checkout the repository(include submodules) and run the installation instructions above. No special instructions needed ;-)
- ack.vim: Vim plugin for
the_silver_searcher
(ag) or ack -- a wicked fast grep - bufexplorer.zip: Quickly and easily switch between buffers. This plugin can be opened with
<leader+o>
- ctrlp.vim: Fuzzy file, buffer, mru and tag finder. It's mapped to
<Ctrl+F>
- lightline.vim: A light and configurable statusline/tabline for Vim
- NERD Tree: A tree explorer plugin for vim
- mru.vim: Plugin to manage Most Recently Used (MRU) files. This plugin can be opened with
<leader+f>
- pathogen.vim: Manage your vim runtimepath
- snipmate.vim: snipmate.vim aims to be a concise vim script that implements some of TextMate's snippets features in Vim
- vim-fugitive: A Git wrapper so awesome, it should be illegal
The leader is ,
, so whenever you see <leader>
it means ,
.
Open bufexplorer to see and manage the current buffers (<leader>o
):
map <leader>o :BufExplorer<cr>
Open MRU.vim to see the recently open files (<leader>f
):
map <leader>f :MRU<CR>
Open ctrlp.vim plugin to quickly find a file or a buffer (<leader>j
or <ctrl>f
):
let g:ctrlp_map = '<c-p>'
NERD Tree mappings:
map <leader>e :NERDTreeToggle<cr>
Disable highlights when you press <leader><cr>
:
map <silent> <leader><cr> :noh<cr>
Smart way to move between windows (<ctrl>j
etc.):
map <leader>j <C-W>j
map <leader>k <C-W>k
map <leader>h <C-W>h
map <leader>l <C-W>l
Closing of the current buffer(s) (<leader>bd
and (<leader>ba
)):
" Close current buffer
map <leader>bd :Bclose<cr>
" Close all buffers
map <leader>ba :1,1000 bd!<cr>
Useful mappings for managing tabs:
map <leader>tn :tabnew<cr>
map <leader>to :tabonly<cr>
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
" Opens a new tab with the current buffer's path
" Super useful when editing files in the same directory
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
Switch CWD to the directory of the open buffer:
map <leader>cd :cd %:p:h<cr>:pwd<cr>
Open ack.vim
for fast search:
map <leader>g :Ack
Toggle paste mode on and off:
map <leader>pp :setlocal paste!<cr>
When you press gv you Ack.vim
after the selected text:
vnoremap <silent> gv :call VisualSelection('gv', '')<CR>
When you press <leader>r
you can search and replace the selected text:
vnoremap <silent> <leader>r :call VisualSelection('replace')<CR>
Surround the visual selection in parenthesis/brackets/etc.:
vnoremap $1 <esc>`>a)<esc>`<i(<esc>
vnoremap $2 <esc>`>a]<esc>`<i[<esc>
vnoremap $3 <esc>`>a}<esc>`<i{<esc>
vnoremap $$ <esc>`>a"<esc>`<i"<esc>
vnoremap $q <esc>`>a'<esc>`<i'<esc>
vnoremap $e <esc>`>a"<esc>`<i"<esc>
Write the file as sudo (works only on Unix). Super useful when you open a file and you don't have permissions to save your changes. Vim tip:
:W
Pressing <leader>ss
will toggle spell checking:
map <leader>ss :setlocal spell!<cr>
Shortcuts using <leader>
instead of special characters:
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
map <leader>s? z=
Just do following:
- Remove
~/.vim_runtime
- Remove any lines that reference
.vim_runtime
in your~/.vimrc