vim插件使用记录

来源:互联网 发布:玩cf网络异常怎么修复 编辑:程序博客网 时间:2024/06/06 10:03

1.gmarik/Vundle.vim
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim

Put this at the top of your .vimrc to use Vundle. Remove plugins you don't need, they are for illustration purposes.

set nocompatible              " be iMproved, requiredfiletype off                  " required" set the runtime path to include Vundle and initializeset rtp+=~/.vim/bundle/Vundle.vimcall vundle#begin()" alternatively, pass a path where Vundle should install plugins"call vundle#begin('~/some/path/here')" let Vundle manage Vundle, requiredPlugin 'gmarik/Vundle.vim'" The following are examples of different formats supported." Keep Plugin commands between vundle#begin/end." plugin on GitHub repoPlugin 'tpope/vim-fugitive'" plugin from http://vim-scripts.org/vim/scripts.htmlPlugin 'L9'" Git plugin not hosted on GitHubPlugin 'git://git.wincent.com/command-t.git'" git repos on your local machine (i.e. when working on your own plugin)Plugin 'file:///home/gmarik/path/to/plugin'" The sparkup vim script is in a subdirectory of this repo called vim." Pass the path to set the runtimepath properly.Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}" Avoid a name conflict with L9Plugin 'user/L9', {'name': 'newL9'}" All of your Plugins must be added before the following linecall vundle#end()            " requiredfiletype plugin indent on    " required

2.yankring

3.自动补全

1).引自:http://vim-wiki.mawercer.de/wiki/topic/text-snippets-skeletons-templates.html

常用自动补全引擎

text snippets, skeletons, templates

2).vim原始支持:

vim 可以对一些流行的编程语言的语法提供自动完成的功能,但是默认是没有启用
在命令模式下,我们可以通过如下命令开始php的自动完成功能
:set omnifunc=phpcomplete#CompletePHP
 在书写一些php函数的时候,按下ctrl+x ,接着按下ctrl+o
下面的示例的截图就是在敲下了"dat"之后,接着按下ctrl+x 以及ctrl+o 的效果


4.注释

NERD_commenter.vim
注释插件,用来注释掉代码的工具,支持“//”、“/* */”两种代码注释方式。
其他的命令:
在Normal或者Visual 模式下:
    * ,ca,在可选的注释方式之间切换,比如C/C++ 的块注释/* */和行注释//
    * ,cc,注释当前行
    * ,c,切换注释/非注释状态
    * ,cs,以”性感”的方式注释
    * ,cA,在当前行尾添加注释符,并进入Insert模式
    * ,cu,取消注释
    * Normal模式下,几乎所有命令前面都可以指定行数
    * Visual模式下执行命令,会对选中的特定区块进行注释/反注释

5.Grep查找

:Grep          - Search for the specified pattern in the specified files:GrepAdd       - Same as ":Grep" but adds the results to the current results:Rgrep         - Run recursive grep:RgrepAdd      - Same as ":Rgrep" but adds the results to the current results

注意是:大写Grep

:Grep find_str *

find_str是你需要查找的对象,*是当前目录下面所有的文件类型

Grep查找当前目录和子目录中的字符串

:Grep -R find_str *

6.tab自动补全函数
msanders/snipmate.vim

没什么说的,装完后,在snippets下有很多自定义的补全.

7.环绕

tpope/vim-surround
Surround.vim is all about "surroundings": parentheses, brackets, quotes, XML tags, and more. The plugin provides mappings to easily delete, change and add such surroundings in pairs.
It's easiest to explain with examples. Press cs"' inside

"Hello world!"

to change it to

'Hello world!'

Now press cs'<q> to change it to

<q>Hello world!</q>

To go full circle, press cst" to get

"Hello world!"

To remove the delimiters entirely, press ds".

Hello world!

Now with the cursor on "Hello", press ysiw] (iw is a text object).

[Hello] world!

Let's make that braces and add some space (use } instead of { for no space): cs]{

{ Hello } world!

Now wrap the entire line in parentheses with yssb or yss).

({ Hello } world!)

Revert to the original text: ds{ds)

Hello world!

Emphasize hello: ysiw<em>

<em>Hello</em> world!

Finally, let's try out visual mode. Press a capital V (for linewise visual mode) followed by S<p class="important">.

<p class="important">  <em>Hello</em> world!</p>

This plugin is very powerful for HTML and XML editing, a niche which currently seems underfilled in Vim land. (As opposed to HTML/XML inserting, for which many plugins are available). Adding, changing, and removing pairs of tags simultaneously is a breeze.

8.更炫的statusline
1)Lokaltog/vim-powerline
配置:
必须:set nocompatible
         set laststatus=2   #这样状态行和命令行各站一行 状态行就常显示了,否则就会不显示
        set powerline_symbols=compatible | unicode |  fancy
    TYPE           DESCRIPTION ~
    compatible     Doesn't use any special characters.
    unicode        Simulates icons and arrows using similar Unicode glyphs.
    fancy          Custom icons and arrows. Requires a patched font.
设置为unicode即可.
        set Powerline_stl_path_style     *Powerline_stl_path_style*
There are currently four ways to display the current path and file name. The
default is to only display the file name like the %t statusline item. By
setting this configuration value you can choose from the following ways
display the current path and file name:
     VALUE      DESCRIPTION ~
    filename   Display only the file name using the %t statusline item.
    short      Display a short path. The home directory is substituted with
               "~", the first directory is displayed with its full name, and
               subsequent directories are shortened to their first letter.
               I.e. "/home/user/foo/bar/baz.vim" becomes "~/f/b/baz.vim" and
               "long/relative/path/foo/bar/baz.vim becomes
               "long/r/p/f/b/baz.vim".
    relative   Display a relative path, similar to the %f statusline item.
    full       Display the full path, similar to the %F statusline item.
以上配置后,如下:

  
2)airline
bling/vim-airline

9.eay-motion

Lokaltog/vim-easymotion
You can also search for n characters, which basically can be used to replace the default search of Vim. It supports incremental highlighting and you can use <Tab> and <S-Tab> to scroll down/up a page. If you press <CR> you get the usual EasyMotion highlighting and can jump to any matching target destination with a single keystroke.
map  / <Plug>(easymotion-sn)
omap / <Plug>(easymotion-tn)
Jump to next/previous match (even on next/previous page)
<Plug>(easymotion-next)
<Plug>(easymotion-prev)

10.netrw.vim
network ready write file/dir
目录浏览:
:Hexplore[!] [dir] 水平分割并探索...........................|netrw-explore|
:Vexplore[!] [dir] 垂直分割并探索...........................|netrw-explore|
可以选择排序风格,使之按 name (名字)、time (时间) 或 size (文件大小) 排序。
"s" 映射允许你在这三个选择之间循环; 目录列表会自动更新以反映选择的风格。
反转排序顺序:                       
用 "r" 键可以在正常和反转两种排序顺序之间切换。
编辑远程文件:
network ready write file or | dir
:Nread "machine:path" uses rcp
:Nread "machine path" uses ftp w/ <.netrc>
:Nread "ftp://[user@]machine[[:#]port]/path" uses ftp w/ <.netrc>
:Nread "http://[user@]machine/path" uses http  uses wget
NETRW 设 置                                             *netrw-settings*
使用 NetrwSettings.vim 插件,
:NetrwSettings
会弹出一个窗口来显示用作 netrw 设置的许多变量。你可以修改这里列出的所有值; 保
存文件时,设置的值就会被应用。在任何行上按 "?" 就可以得到每个变量功能的帮助。
11.vim中文文档的安装
wget  http://sourceforge.net/projects/vimcdoc/files/vimcdoc/1.8.0/vimcdoc-1.8.0.tar.gz
解压 
安装 ./vimdoc.sh 
12.vim安装command-t
1)编译vim,需要很多依赖
参考:https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source
yum install libncurses5-dev libgnome2-dev libgnomeui-dev \
libgtk2.0-dev libatk1.0-dev libbonoboui2-dev \
libcairo2-dev libx11-dev libxpm-dev libxt-dev python-dev ruby-dev mercurial
2)./configure --with-features=huge \
            --enable-multibyte \
            --enable-rubyinterp \
            --enable-pythoninterp \
            --with-python-config-dir=/usr/lib/python2.6/config \
                         --enable-gui=gtk2 --enable-cscope 
3)vim --version | grep ruby
显示+ruby +python  ok
4) cd command-t/ruby/

 ruby extconf.rb  make
然后可以正常使用了.
默认<leader>t 打开快捷窗口. ctrl-c:取消. ,ctrl+v:vsplit 打开文件

13.YouCompleteMe
14.Yggdroot/indentLine
显示缩进线
15.Raimondi/delimitMate
括号自动补全安装完 即可用
16.fencview.vim
如果发现浏览的文件是乱码,是不是很头疼,不要紧,只要输入命令 :FencAutoDetect 来自动识别文件的编码。非常非常不错的插件哟。

vim-scripts/FencView.vim







0 0
原创粉丝点击