Leader key

Default is \ (backslash).

Be aware that when you do press your <leader> key you have only 1000ms (by default) to enter the command following it.

Omni completion

Vim自带的自动完成 http://vim.wikia.com/wiki/Omni_completion

Ctrl-xCtrl-o

Node.vim

https://github.com/moll/vim-node

gf 打开node module文件

require(".")

ctrl + ^ 跳转回上一个文件。

tern

Shortcut Command Description
<Leader> td :TernDoc Documentation under cursor
<Leader> tb :TernDocBrowse Browse documentation
<Leader> tt :TernType Type hints
<Leader> td :TernDef Jump to definition (yes, ‘td’ is duplicated)
<Leader> tpd :TernDefPreview Jump to definition inside preview
<Leader> tsd :TernDefSplit Definition in new split
<Leader> ttd :TernDefTab Definition in new tab
<Leader> tr :TernRefs All references under cursor
<Leader> tR :TernRename Rename variable

Vim distribution

http://krampstudio.com/webvim/

Copy and paste

Command 1 Command 2 Command 3 Description
    "*yy yank current line to * register which is the clipboard ( to paste )
:y+     yank current line to paste
  "+y "*y yank visual area into paste buffer
  "+p "*p insert from paste buffer

See Registers for more details.

refs:

save file

F2 to save

inoremap <F2> <c-o>:w<cr>

Install plugins

:Helptags to update document, :help editconfig to show help for editconfig plugin.

example

https://github.com/xxd3vin/env/tree/master/.vim/bundle

https://github.com/xxd3vin/env/blob/master/README.md#install-new-vim-plugin

suggest plugin list

Registers

To access a register, type "a before any command ( a is the register name ).

For example, "*yy will copy the current line to register * ( which is the clipboard ).

refs:

Searching tips

  1. v to select text
  2. y to yank to register 0
  3. / to search
  4. Ctrl+R then type the register name 0, to paste the result

Search insensitive

When you search in vim using /, e.g. /foo, the Foo will not match. Because the default search is case sensitive.

By using /\cfoo or /foo\c (A \c escape sequence), that could match both Foo and foo.

https://stackoverflow.com/a/2287449/4685522

A better solution is to use smartcase.

:set ignorecase
:set smartcase

If you search for something containing uppercase characters, it will do a case sensitive search; if you search for something purely lowercase, it will do a case insensitive search.

https://stackoverflow.com/a/2288438/4685522

Another solution is use case insensitive by default (:set ignorecase), and use \C to make a case sensitive search.

list all known file type

Type :setfiletype (with a space afterwards), then press Ctrl-d.

https://vi.stackexchange.com/a/5782

find what filetype is loaded in vim

:set filetype?

https://stackoverflow.com/a/2779390/4685522

compare plugins

  • Command-T v/s Ctrlp.vim v/s FuzzyFinder

buffers, windows and tabs

https://sanctum.geek.nz/arabesque/buffers-windows-tabs/

http://vim.wikia.com/wiki/Using_tab_pages

Open a new tab without giving filename :tabedit

Open a new tab and give a filename :tabedit foo.js

See also

References

  • http://vimawesome.com/