Skip to content

pengz1/vim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

This is my vim configuration file, you can copy it as you well.

Installation

1.Get local copy

https://github.com/pengz1/vim.git

2.Link vim config file

ln -s vim/vimrc ~/.vimrc

3.Install Vundle

mkdir .vim/bundle
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

or directly copy .vim/Vundle.vim from vim/Vundle.vim.

4.Install plugins Open Vim, and type :PluginInstall, wait until all plugins are installed.

5.Install dependancy (Take ubuntu for example)

  • System dependancy
sudo apt-get install -y silversearcher-ag  # This is what vim-ag needs
sudo apt-get install -y build-essential cmake python-dev    #This is plugin 'YCM' needs
  • Javscript
sudo apt-get install nodejs    #if you have installed node.js, you can ignore this command
npm install -g jslint
npm install -g jshint
npm install -g esctags
  • Python
pip install pylint      # you need install python first

6.Compile YouCompleteMe Follows the guide in https://github.com/Valloric/YouCompleteMe, this will take very long time (around 1 hour in my PC). If you vim version is less than 7.4.1578, follow https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source to build a new version vim. Note: While install vim you should only configure one of Python3.x or Python2.7, otherwise YCM will report errors.

7.Install for command-t

sudo apt-get install ruby-full
cd ~/.vim/bundle/command-t/ruby/command-t/ext/command-t
ruby extconf.rb
make

Key Mapping

Vim Cheat Sheet

Download the cheat sheet from http://coolshell.cn/articles/5479.html

Vim General

Key Function
* (visual mode)Search next for the current selection
* (normal mode) Keep search pattern at the center of the screen
# (visual mode) Search previous for the current selection
# (normal mode) Keep search pattern at the center of the screen
; Enter command line, same as :
n (normal mode) Keep search pattern at the center of the screen
N (normal mode) Keep search pattern at the center of the screen
U easier redo, same as Ctrl+r
v expand selection region (Plugin: vim-expand-region)
V shrink selection region (Plugin: vim-expand-region
w!! sudo & write a file
Y Select whole line
,q Quickly close current window, same as :q
,v Select block
,w Fast saving, same as :w!
:w!! Sudo write a file
{Space} Page down
CTRL+@ Page up

Fn Keys

Key Function
F2 Toggle Tagbar (Plugin: tagbar)
F3 Do Syntastic check
F4 Toggle Syntastic error window
F5 Toggle NERDTree (Plugin: NERDTree)
F8 Switch Color Scheme (Plugin: vim-colorscheme-switch)
F10 Quick run current file (plugin: quickrun)
F11 Toggle line number and indent line, useful when you copy screen
F12 Toggle Paste mode

CTRL+?

Key Function
CTRL+d Scroll down half a page
CTRL+f Prompt in commandline to use CtrlSF to search
CTRL+i Retrace you movement in file in forwards
CTRL+m Select current word and jump to next (Plugin:vim-multiple-cursors)
CTRL+o Retrace your movement in file in backwards
CTRL+p Select previous word and jump to previous (Plugin: vim-multiple-cursors)
CTRL+s Save current file, mapping of :w!
CTRL+t Open the command-t file window
CTRL+u Scrool up half a page
CTRL+x Skip current word (Plugin: vim-multiple-cursors)
CTRL+y Format source file (plugin: vim-autoformat)

{Leader}?

Key Function
,b Open a window listing all buffers (Plugin: buffergator)
,B Close the buffer catalog (Plugin: buffergator)
,n Toggle NERDTree
,r Quick run current file (plugin: quickrun)
,w Fast saving, same as :w!
,q Quickly close current window, same as :q
,v Select block
,/ Remove highlight

` Hotkey

Key Function
`e create a new line in the end of file and jump to it
`b move backward to last cursor position
`` move backward to last cursor position
`f move foreward to last cursor position

Line Movement

Key Function
,lj Move current line to above
,lk Move current line to below

Tab

Key Function
,te Open a new tab with the current buffer's path, Super useful when editing files in the same director
,tm Tab move
,tn Go to next tab
,to Tab only
,tp Go to previous tab
,tq Close tab
,tt Create new tab
,1 Go to 1st tab
,2 Go to 2nd tab
,3 Go to 3rd tab
,4 Go to 4th tab
,5 Go to 5th tab
,6 Go to 6th tab
,7 Go to 7th tab
,8 Go to 8th tab
,9 Go to 9th tab
,0 Go to last tab

Window

Key Function
,wh Go to left window
,wj Go to above window
,wk Go to below window
,wl Go to right window
,wq Close window
,ww Switch to next window
,wz Toggle zoom current window

Buffer

Key Function
,b Open a window listing all buffers (Plugin: buffergator)
,B Close the buffer catalog (Plugin: buffergator)
,bb Create new buffer
,bn Go to next buffer
,bp Go to previous buffer

Misc

Key Function
,~m Remove the windows ^M when the encoding gets messed up
gV hight last inserted text

Plugin

Plugin List

" Color scheme
Plugin 'xolox/vim-colorscheme-switcher'
Plugin 'xolox/vim-misc'

Plugin 'altercation/vim-colors-solarized'
Plugin 'crusoexia/vim-monokai'
Plugin 'zenorocha/dracula-theme', {'rtp': 'vim/'}

" General plugins
"Plugin 'Lokaltog/powerline'
"Plugin 'ashwin/vim-powerline'
Plugin 'bling/vim-airline'
Plugin 'scrooloose/nerdtree'
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'Xuyuanp/nerdtree-git-plugin'
"Plugin 'bufexplorer.zip'
Plugin 'jeetsukumaran/vim-buffergator'
"Plugin 'rking/ag.vim'
Plugin 'dyng/ctrlsf.vim'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'kshenoy/vim-signature'
Plugin 'ntpeters/vim-better-whitespace'
Plugin 'terryma/vim-expand-region'
Plugin 'easymotion/vim-easymotion'
Plugin 'matze/vim-move'
Plugin 'wincent/command-t'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'tacahiroy/ctrlp-funky'
Plugin 'jasoncodes/ctrlp-modified.vim'

Plugin 'tpope/vim-repeat'
"Plugin 'Shougo/neocomplete.vim'
"Plugin 'Shougo/neosnippet.vim'
"Plugin 'Shougo/neosnippet-snippets'
"Plugin 'Shougo/vimshell.vim'
"Plugin 'Shougo/vimproc.vim'

" Common plugins for source codes
Plugin 'scrooloose/syntastic'
Plugin 'Chiel92/vim-autoformat'
Plugin 'Valloric/YouCompleteMe'
Plugin 'tComment'
"Plugin 'Yggdroot/indentLine'
Plugin 'nathanaelkane/vim-indent-guides'
"Plugin 'junegunn/vim-easy-align'
Plugin 'godlygeek/tabular'
"Plugin 'tpope/vim-surround'
Plugin 'majutsushi/tagbar'
Plugin 'thinca/vim-quickrun'
Plugin 'kien/rainbow_parentheses.vim'
Plugin 'airblade/vim-gitgutter'
Plugin 'tpope/vim-fugitive'

" Javascript/Node.js
Plugin 'moll/vim-node'
"Plugin 'walm/jshint.vim'
Plugin 'marijnh/tern_for_vim'
Plugin 'pangloss/vim-javascript'
Plugin 'crusoexia/vim-javascript-lib'
Plugin 'jiangmiao/simple-javascript-indenter'
Plugin 'ramitos/jsctags'

" Python
Plugin 'klen/python-mode'

" JSON
Plugin 'elzr/vim-json'

Global Key Mapping

Key Function
F5 or ,n Toggle NERDTree

NERDTree Window Only Key Mapping

Key Function
{Enter} or o Open current file or folder
s Open the file in horizontal split window
v Open the file in vertical split window

User Guide

Plugin: bufexplorer

Use vim-buffergator instead.

Global

Key Function
,b Open a window listing all buffers
,B Close the buffer catalog

Vim-buffergator Only

Key Function
{Enter} or o Edit the selected buffer in the prevoius window
go open the currently selected buffer in the previous window, but with focus remaining in the buffer catalog ("42go" will do the same, but will select buffer number 42).
{Number}{Enter} Open buffer number in prevous window, such as 42*{Enter}, 5{Enter}*
A Toggle zoom in/zoom out the vim-buffergator window
d Delete the selected buffer
D Unconditionally delete the selected buffer.
i open the currently selected buffer in new horizontal split. "42i" will do the same
I open the buffer in a new vertical split, but keep the focus in the buffer catalog. "42I" will do the same.
q Quit the index/catalog window.
r Update (rebuild/refresh) index.
s Open the currently selected buffer in new vertical split. "42s" will do the same.
S open the buffer in a new vertical split, but keep the focus in the buffer catalog. "42S" will do the same
t open the currently selected buffer in new tab ("42t" will do the same, but will select buffer number 42)
x Wipe the selected buffer.
X Unconditionally wipe the selected buffer.
{Space} or CTRL+N Go to the next buffer entry (or, if [count] is given, buffer with number [count]), and preview it in the previous window.
CTRL+{Space} or CTRL+P Go to the previous buffer entry (or, if [count] is given, buffer with number [count]), and preview it in the previous window.

Plugin: command-t

Global Key Mapping

Key Function
CTRL+t Open the command-t file window

Command-t Window Only Key Mapping

Key Function
{Enter} open the selected file
CTRL+{Enter} open the selected file in a new split window
CTRL+s open the selected file in a new split window
CTRL+v open the selected file in a new vertical split window
CTRL+t open the selected file in a new tab
CTRL+j select next file in the file listing
CTRL+n select next file in the file listing
{Down} select next file in the file listing
CTRL+k select previous file in the file listing
CTRL+p select previous file in the file listing
{Up} select previous file in the file listing
CTRL+f flush the cache (see :CommandTFlush for details)
CTRL+q place the current matches in the quickfix window
CTRL+c cancel (dismisses file listing)

Custom Key Mapping

Key Function
,mv Toggle visual of signature

Plugin Built-in Key Mapping

Key Function
mx Toggle mark 'x' and display it in the leftmost column
dmx Remove mark 'x' where x is a-zA-Z
m, Place the next available mark
m. If no mark on line, place the next available mark. Otherwise, remove (first) existing mark.
m- Delete all marks from the current line
m*{Space}* Delete all marks from the current buffer
]` Jump to next mark
[` Jump to prev mark
]' Jump to start of next line containing a mark
[' Jump to start of prev line containing a mark
`] Jump by alphabetical order to next mark
`[ Jump by alphabetical order to prev mark
'] Jump by alphabetical order to start of next line having a mark
'[ Jump by alphabetical order to start of prev line having a mark
m/ Open location list and display marks from current buffer
m[0-9] Toggle the corresponding marker !@#$%^&*()
m*{S-[0-9]}* Remove all markers of the same type
]- Jump to next line having a marker of the same type
[- Jump to prev line having a marker of the same type
]= Jump to next line having a marker of any type
[= Jump to prev line having a marker of any type
m? Open location list and display markers from current buffer
m*{BS}* Remove all markers

Screenshot

Plugin: ctrlsf.vim

Global

Key Function
CTRL+F (visual mode) search selected words; (normal mode) prompst for searching
\ Input :CtrlSF foo in command line where foo is word under the cursor.
,fv Toggle CtrlSF result window

CtrlSF Result Window Only

Key Function
{Enter} Open corresponding file of current line in the window which CtrlSF is launched from.
t Like Enter but open file in a new tab.
p Like Enter but open file in a preview window.
O Like Enter but always leave CtrlSF window opening.
T Lkie t but focus CtrlSF window instead of new opened tab.
q Quit CtrlSF window.
n Move cursor to next match.
N Move cursor to previous match.

Plugin: ctrlp

Key Function
CTRL+p or ,p Trigger ctrlp in file mode
CTRL+pr or ,pr Trigger ctrlp in MRU mode (Most Recently Used)
CTRL+px or ,px Trigger ctrlp in mixed mode
CTRL+pb or ,pb Trigger ctrlp in buffer mode

Inside ctrlp result window:

Key Function
<Esc> or CTRL+c Exit ctrlp
<F5> purge the cache for the current directory to get new files, remove deleted files and apply new ignore options.
<F7> Wipe the MRU list; Delete MRU entries marked by CTRL+z
CTRL+f, CTRL+b Cycle between mode
CTRL+d Cycle between filename only mode and full-path mode
CTRL+r Switch to regexp mode
CTRL+j, CTRL+k, <Up>, <Down> Navigate the result list
CTRL+t Open the selected entry in a new tab
CTRL+v Open the selected entry in vertical split window
CTRL+x, CTRL+s Open the selected entry in horizontal split window
CTRL+y Create a new file and its parent directories
CTRL+z Mark/unmark multiple files and CTRL+o to open them
CTRL+o Open files marked by CTRL+z
Shift+Tab Toggle the focus between the match window and the prompt

Key Function
CTRL+m Select current word and jump to next
CTRL+p Select previous word and jump to previous
CTRL+x Skip current word
{ESC} Quit from multiple cursor mode

User Guide

Key Function
,,h easymotion-linebackward
,,j easymotion-j
,,k easymotion-k
,,l easymotion-lineforward

Plugin: vim-move

Key Function
CTRL+j Move current line/selections down (Plugin: vim-move)
CTRL+k Move current line/selections up
Key Function
,*{Space}*d Strip white space

Plugin: vim-quickrun

Key Function
,r Quick run current file (plugin: quickrun)
F10 Quick run current file (plugin: quickrun)

Plugin: Syntastic

Key Function
F3 Do Syntastic check
F4 Toggle Syntastic error window
,sn Go to next syntastic error
,sp Go to prevoius syntastic error

Key Function
,: <C-x><C-o>
ALT + g Go to definition

Plugin: tComment

Key Function
CTRL + / Comment current line or selected region
,cb Comment block, only useful on visual mode
,cl Comment one line

Plugin: tabular

Key Function
,a& align by &
,a= align by =
,a: align by :
,a:: align by ::
,a, align by ,
,a| align by |

See following video for usage: http://media.vimcasts.org/videos/29/alignment.ogv

Plugin: vim-fugitive

Key Function
,gb git blame
,gd git diff
,gl git log
,gs git status
,gt git tab edit
,gv git vertical split

Plugin: GitGutter

Key Function
,vv Toggle GitGutter
,vn Go to next modification
,vp Go to previous modification
Key Function
F8 Switch to next color scheme

Color Scheme

The color scheme is the famous solarized.

Font

To support the vim-airline or vim-powerline, the terminal font must be patched. You don't need to patch by yourself, you just need to download and install the patched font from following address:

References

About

Personal vim configure

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published