標籤:blog http ar os 使用 sp for 檔案 div
背景:中午醒來,飯都沒吃,突然想到要給vim增加個程式碼片段的功能,因為昨天使用了gedit的程式碼片段,感覺不錯。為什麼不直接使用gedit呢?因為我相信把時間投入到vim是不會錯的,精通vim就好了。。。。就這樣的一個想法,讓我搞到了快5點。 T_T
1 安裝vundle
地址在:https://github.com/gmarik/Vundle.vim,不過不需要在這邊下載什麼,看看文檔就好
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim#沒有git的話 yum install git#這樣就安裝好了,不騙你
2 配置 .vimrc 在家目錄下,沒有就建立一個
然後在.vimrc 的第一行加入如下代碼,無腦拷貝就好了
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" To ignore plugin indent changes, instead use:"filetype plugin on"" Brief help" :PluginList - lists configured plugins" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate" :PluginSearch foo - searches for foo; append `!` to refresh local cache" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal"" see :h vundle for more details or wiki for FAQ" Put your non-Plugin stuff after this line
要安裝外掛程式就在call vundle#begin()和call vundle#end()之間加入外掛程式名稱,比如要安裝ultisnips,
Plugin ‘SirVer/ultisnips‘ #這個是沒有現成的程式碼片段的,自己怎麼配置還沒研究,但是可以用別人的,看下一行Plugin ‘honza/vim-snippets‘ #這個就應有就有了,都在 .vim/vundle/vim-snippets/snippets/下面#然後配置下面3行,沒有的話是用不了程式碼片段功能的。這個是觸發設定let g:UltiSnipsExpandTrigger="<tab>"let g:UltiSnipsJumpForwardTrigger="<c-b>" #可以自行配置,比如我的<c-l>,作用是跳到下一個預留位置let g:UltiSnipsJumpBackwardTrigger="<c-z>" #我的<c-h>,上一個預留位置
這樣真的就萬事具備,只欠第3步,安裝外掛程式了
3 開啟vim 執行 :PluginInstall (安裝外掛程式的意思), 等完成了會提示 done!
4 使用
先建立檔案,比如 $ >test.html然後開啟$ vim test.html然後輸入form 按下tab鍵,。。。。。
vim 程式碼片段:通過vundle外掛程式管理器安裝ultisnips |centos6.5|vim7.2