vim配备和使用快捷键汇总

vim配置和使用快捷键汇总

 

使用的是我老大的vim配置文件,具体地址可见:https://github.com/wongyouth/vimfiles

A handful of plugins for vim all maintained in one bundle subdirectory, useful vim configuration, espacially for Rails coding. All plugins are included as submodules, so you can get plugins updated in one command that makes life easier.

One Line Installation:

bash < <(curl -s https://raw.github.com/wongyouth/vimfiles/master/install.sh)

Old School Installation:

# Checkout configuration files
git clone git://github.com/wongyouth/vimfiles ~/vimfiles

# Create symlinks
ln -s ~/vimfiles ~/.vim
echo "source ~/.vim/vimrc" > ~/.vimrc

# Switch to the `~/.vim` directory, and fetch submodules
cd ~/.vim
git submodule init
git submodule update

Usage

  • :Helptags for build vim plugin doc
  • F7 for NERDTree toggle
  • F4 for paste toggle
  • CTRL-B for showing BufExplorer
  • <leader>cc for comment out
  • <leader>c<SPACE> for removing comment mark
  • <leader>a= for tabular =
  • <leader>a: for tabular :
  • <leader>a> for tabular =>
  • CTRL-y, for zencoding
  • yss- for <% -%>
  • yss= for <%= %>
  • <leader> in most cases is “\” key.

  • :1R user.rb或:find user.rb 快速文件切换
  • :Rfunctionaltest 在controller中可以直接跳转至对应的spec文件
  • :Rcontroller        在spec文件中跳转至对应的controller文件
  • :RVfunctionaltest 将spec文件和controller文件多屏显示(横屏),竖屏维RS
  • 当光标停留在某个函数上时使用gf可直接跳转至函数定义的文件中
  • Ctrl + v   选择多个字符
  • Shift + v  选择多行
  • \a>          对含有“=>”的表达式自动对齐
  • e!            重新载入文件
  • ysiW)       对光标停留的单词加括号“()”
  • :sp 文件名       将该文件在一个新的窗口中打开
  • :Ggrep 字段名        在当前文件夹下递归搜索含有该字段的文件 :cnext 下一个,:copen 打开所有进行选择
  • 在一段文字(若干行)前插入文字或空格,(1)Ctrl + v;  (2)shift + i (在最前面插入)
  • :%s= *$==      将所有行尾多余的空格删除
  • :g/^\s*$/d        将所有不包含字符(空格也没有)的空行删除
  • :%s/old/new/g 全文替换将old替换为new(:%s/old/new/gc 代表“confirm”每次替换要求确认)
  • :n1,n2s/old/new/g   在n1行到n2行范围内进行替换
  • :s/old/new/g             替换当前行的所有匹配
  • zz 到屏幕*