Skip to content
yaotian edited this page Dec 18, 2013 · 1 revision

Yaotian's Vim config

Installation

if you are using Ubuntu:

curl -L https://raw.github.com/yaotian/.vim/master/install_ubuntu.sh

Otherwise:

curl -L https://raw.github.com/yaotian/.vim/master/install.sh|bash

hot tips

  • ,ee # to open vimrc file

  • ,zz # to open markdown document folder

  • ,n # to open file list

  • ,t # to open function list

  • ,q # to quickly quite

  • ,a # to search

  • ,j # to check javascript using jshint

  • F # format the python codes

  • ,w -> Beginning of the word.

  • ,f + {char} -> Find {char} to the right.

  • % -> Jump between brackets and html/xml tags

  • <leader> + c + <space> -> Toggle comment

  • gs # to git status

  • ga # to git add

  • gc # to git commit

  • gp # to git push origin master

Shortcuts

  • Tab -> Rotate across the completion list
  • Tab -> Expand snippets or jump to the next placeholder of snippet
  • shift + Tab -> This is really the Tab
  • Ctrl + j -> Call zen-coding expansion on html tags
  • Ctrl + tab -> Call ultimate snippets list
  • Ctrl + j -> Call zen-coding expansion on html tags

Movie teaching zencoding.vim

Screenshots

Completions Snippets

Fast navigation

  • matchit - Extended % matching for HTML, LaTeX, and many other languages.
  • EasyMotion - Vim motions on speed!

Doing fixes should be as fast as possible!

Fast editing

  • surround - Easily delete, change and add such surroundings in pairs.
  • nerdcommenter - Easy commenting of code for many filetypes.
  • Gundo - visualize your Vim undo tree.
  • tabular - Vim script for text filtering and alignment.
  • IndentGuides - A Vim plugin for visually displaying indent levels in code.

Tutorial

:help text-objexts
:help surround
:help tabular

Shortcuts

  • % -> Jump between brackets and html/xml tags
  • <leader> + c + <space> -> Toggle comment
  • F3 -> Toggle Gundo viewer
  • F4 -> Toggle Indent Guides
  • F6 -> Format code

IDE features

  • nerdtree - A tree explorer plugin for navigating the filesystem.
  • tabbar - Add tab bar and quickt tab switch with alt+1~9.
  • tagbar - Displays the tags of the current file in a sidebar.
  • ack-vim - Front for the Perl module App::Ack.
  • ctrlp - Fuzzy file, buffer, mru and tag finder.
  • powerline - The ultimate vim statusline utility.
  • fugitive - a Git wrapper so awesome, it should be illegal.
  • syntastic - Syntax checking hacks for vim.

Dependencie

yaourt -S ack ctags                  # ArchLinux
sudo apt-get install ack-grep ctags  # Ubuntu
brew install ack ctags               # OS X
sudo easy_install autopep8           # This is for code format
go get github.com/nsf/gocode      # for golang  note: need setup GOPATH

For syntax check tools:

Languages Lint Tools Install guide
C gcc built-in
CPP g++ built-in
CoffeeScript coffee npm install -g coffeelint
CSS csslint npm install -g csslint
Erlang escript built-in
Go go built-in
Haml haml built-in
Haskell ghc-mod cabal install ghc-mod
HTML tidy built-in
Java javac built-in
Javascript jslint/jshint npm install -g jslint/jshint
Json jsonlint npm install -g jsonlint
Less lessc built-in
Lisp clisp built-in
Lua luac built-in
Perl perl built-in
PHP php built-in
Puppet puppet built-in
Python pylint/pyflakes/flake8 sudo pip install pylint/pyflakes/flake8
Ruby ruby built-in
Scala scala built-in
Sass sass built-in
Scss scss/compass gem install compass
XML xmllint built-in
YAML js-yaml npm install -g js-yaml

Shortcuts

  • F6 -> Format Code
  • Ctrl + p -> Toggle ctrlp
  • Alt + 1~9 -> Switch between multiple buffers
  • Ctrl + h/j/k/l -> Moving between spilt windows
  • :Ack or <leader> + a -> Toggle Ack searching

Other Utils

  • fcitx-status - automatic change status of fcitx in vim.
  • togglemouse - Toggles the mouse focus between Vim and your terminal emulator, allowing terminal emulator mouse commands, like copy/paste.

Shortcuts

  • F12 -> Toggle Mouse

Better syntax/indent for language enhancement

  • markdown - Syntax highlight for Markdown text files.
  • jquery - Syntax file for jQuery in ViM.
  • javascript - Vastly improved vim's javascript indentation.
  • coffee-script - CoffeeScript support for vim.
  • html5 - HTML5 omnicomplete and syntax.
  • haml - Vim runtime files for Haml, Sass, and SCSS.

Themes

  • blackboard - Textmate's Blackboard theme for vim (with iTerm2 theme)
  • molokai - A port of the monokai scheme for TextMate
  • solarized - precision colorscheme for the vim text editor
  • vividchalk - colorscheme based on the Vibrant Ink theme for TextMate
  • distinguished - A dark vim color scheme for 256-color terminals.

Additional functions

  1. File encoding auto detection
  • Hightlight current line and column
  • Automatically jump to the last edited location
  • :w/:wq error correction
  • Remove trailing white space
  • Code folding is disabled, enable it as you wish
  • Indent style:
    • JavaScript - Use soft-tabs with a two space indent(According to this Post).
    • HTML/CSS - Use soft-tabs with a two space indent(According to Google and Github's HTML/CSS style guide, just Google it).
    • PHP - Use soft-tabs with a two space indent(According to Apache PHP Style Guide).
    • Python - Use soft-tabs with a four space indent(PEP8).

Known issues

  • Compeletions are not well supported for statically typed languages(c/c++)
  • Snippets are not shown in completions popups
  • May has some conflicts with GVIM

Work aroud

用git操作文件如果commit没有输入comment后出现这个问题

    fatal: index file corrupt

解决办法:

    rm -rf .git/index 
    git reset