多语言展示
当前在线:1863今日阅读:84今日分享:32

VI编辑器配置

ubuntu 14 VIM配置
工具/原料
1

ctags

2

taglist

3

spf13

4

neocomplete

5

dotvim

方法/步骤
1

sudo apt-get install vim如果VIM已安装跳过

2

下载,ctags ,taglist, neocomplete,spf13-vim,dot-vimctags可以直接使用在线方式安装sudo apt-get install ctags

3

taglist下载后解压将文件复制到VIM里面语句如下cp  doc/taglist.txt  /usr/share/vim/vim74/doc/cp  plugin/taglist.vim  /usr/share/vim/vim74/plugin/

4

neocomplete下载后解压unzip neocomplete复制所有文件到~/.vim目录下即可

5

下载spf13解压后,执行./bootstrap.sh中途无需任何操作,直到全部完成,他会自动安装Vbundle所有的插件

6

下载dot-vim解压后复制到~/.vim里面,将其中vimrc复制到/etc/vim里面/etc/vim/vimrc的配置如下,里面有冲突的设置,在vimrc里面注释掉就可以了taglist的配置如下~/.vimrc不需要任何修改某些情况下可能需要添加引入,一般不需要添加source /etc/vim/vimrc

7

source ~/.vim/bundles.vim' encoding dectectionset fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1' enable filetype dectection and ft specific plugin/indentfiletype onfiletype plugin onfiletype indent onfiletype plugin indent on' enable syntax hightlight and completionsyntax on'--------' Vim UI'--------' color schemeset background=darkcolor solarizednnoremap :TlistTogglelet Tlist_Ctags_Cmd = '/usr/bin/ctags'   '设定Linux系统中ctags程序的位置'let Tlist_Auto_Open = 1let Tlist_Show_One_File = 1            ' 不同时显示多个文件的tag,只显示当前文件的let Tlist_Exit_OnlyWindow = 1          ' 如果taglist窗口是最后一个窗口,则退出vimlet Tlist_Use_Right_Window = 1         ' 在右侧窗口中显示taglist窗口let Tlist_File_Fold_Auto_Close=1       ' 自动折叠当前非编辑文件的方法列表let Tlist_Auto_Update = 1let Tlist_Sort_Type='name'             '按照名称排序let Tlist_Hightlight_Tag_On_BufEnter = 1let Tlist_Enable_Fold_Column = 0let Tlist_Process_File_Always = 1let Tlist_Display_Prototype = 0let Tlist_Compact_Format = 1set tags+=/usr/include/tagsset tags+=./tagsset tags+=~/tagsset tags+=tagsset autochdirset completeopt=preview,menu '打开文件类型检测, 加了这句才可以用智能补全set completeopt=longest,menu  set nocp'启动的时候不显示那个援助索马里儿童的提示set shortmess=atIautocmd FileType c set tags+=/usr/include/tags' highlight current lineau WinLeave * set nocursorline nocursorcolumnau WinEnter * set cursorline cursorcolumnset cursorline cursorcolumn' searchset incsearch'set highlight ' conflict with highlight current lineset ignorecaseset smartcase' editor settingsset history=1000set nocompatibleset nofoldenable                                                  ' disable folding'set confirm                                                       ' prompt when existing from an unsaved fileset backspace=indent,eol,start                                    ' More powerful backspacingset t_Co=256                                                      ' Explicitly tell vim that the terminal has 256 colors 'set mouse=a                                                       ' use mouse in all modesset report=0                                                      ' always report number of lines changed                'set nowrap                                                        ' dont wrap linesset scrolloff=5                                                   ' 5 lines above/below cursor when scrollingset number                                                        ' show line numbersset showmatch                                                     ' show matching bracket (briefly jump)set showcmd                                                       ' show typed command in status barset title                                                         ' show file in titlebarset laststatus=2                                                  ' use 2 lines for the status barset matchtime=2                                                   ' show matching bracket for 0.2 secondsset matchpairs+=<:>                                               ' specially for html' set relativenumber' Default Indentationset autoindentset smartindent     ' indent whenset tabstop=4       ' tab widthset softtabstop=4   ' backspaceset shiftwidth=4    ' indent width' set textwidth=79' set smarttabset expandtab       ' expand tab to spaceautocmd FileType php setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=120autocmd FileType ruby setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=120autocmd FileType php setlocal tabstop=4 shiftwidth=4 softtabstop=4 textwidth=120autocmd FileType coffee,javascript setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=120autocmd FileType python setlocal tabstop=4 shiftwidth=4 softtabstop=4 textwidth=120autocmd FileType html,htmldjango,xhtml,haml setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=0autocmd FileType sass,scss,css setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=120' syntax supportautocmd Syntax javascript set syntax=jquery   ' JQuery syntax support' jslet g:html_indent_inctags = 'html,body,head,tbody'let g:html_indent_script1 = 'inc'let g:html_indent_style1 = 'inc''-----------------' Plugin settings'-----------------' Rainbow parentheses for Lisp and variantslet g:rbpt_colorpairs = [    \ ['brown',       'RoyalBlue3'],    \ ['Darkblue',    'SeaGreen3'],    \ ['darkgray',    'DarkOrchid3'],    \ ['darkgreen',   'firebrick3'],    \ ['darkcyan',    'RoyalBlue3'],    \ ['darkred',     'SeaGreen3'],    \ ['darkmagenta', 'DarkOrchid3'],    \ ['brown',       'firebrick3'],    \ ['gray',        'RoyalBlue3'],    \ ['black',       'SeaGreen3'],    \ ['darkmagenta', 'DarkOrchid3'],    \ ['Darkblue',    'firebrick3'],    \ ['darkgreen',   'RoyalBlue3'],    \ ['darkcyan',    'SeaGreen3'],    \ ['darkred',     'DarkOrchid3'],    \ ['red',         'firebrick3'],    \ ]let g:rbpt_max = 16autocmd Syntax lisp,scheme,clojure,racket RainbowParenthesesToggle' tabbarlet g:Tb_MaxSize = 2let g:Tb_TabWrap = 1hi Tb_Normal guifg=white ctermfg=whitehi Tb_Changed guifg=green ctermfg=greenhi Tb_VisibleNormal ctermbg=252 ctermfg=235hi Tb_VisibleChanged guifg=green ctermbg=252 ctermfg=white' easy-motionlet g:EasyMotion_leader_key = ''' Tagbarlet g:tagbar_left=1let g:tagbar_width=30let g:tagbar_autofocus = 1let g:tagbar_sort = 0let g:tagbar_compact = 1' tag for coffeeif executable('coffeetags')  let g:tagbar_type_coffee = {        \ 'ctagsbin' : 'coffeetags',        \ 'ctagsargs' : '',        \ 'kinds' : [        \ 'f:functions',        \ 'o:object',        \ ],        \ 'sro' : '.',        \ 'kind2scope' : {        \ 'f' : 'object',        \ 'o' : 'object',        \ }        \ }  let g:tagbar_type_markdown = {    \ 'ctagstype' : 'markdown',    \ 'sort' : 0,    \ 'kinds' : [        \ 'h:sections'    \ ]    \ }endif' Nerd Treelet NERDChristmasTree=0let NERDTreeWinSize=30let NERDTreeChDirMode=2let NERDTreeIgnore=['\~$', '\.pyc$', '\.swp$']' let NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$',  '\~$']let NERDTreeShowBookmarks=1let NERDTreeWinPos = 'right'' nerdcommenterlet NERDSpaceDelims=1' nmap :NERDComToggleCommentlet NERDCompactSexyComs=1' ZenCodinglet g:user_emmet_expandabbr_key=''' powerline'let g:Powerline_symbols = 'fancy'' NeoComplCachelet g:neocomplcache_enable_at_startup=1'设置不自动弹出补全列表let g:neoComplcache_disableautocomplete=1'let g:neocomplcache_enable_underbar_completion = 1'let g:neocomplcache_enable_camel_case_completion = 1let g:neocomplcache_enable_smart_case=1let g:neocomplcache_min_syntax_length = 3let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'set completeopt-=previewlet g:neocomplcache_enable_quick_match = 1'Note: This option must set it in .vimrc(_vimrc).  NOT IN .gvimrc(_gvimrc)!' Disable AutoComplPop.let g:acp_enableAtStartup = 0' Use neocomplete.let g:neocomplete#enable_at_startup = 1' Use smartcase.let g:neocomplete#enable_smart_case = 1' Set minimum syntax keyword length.let g:neocomplete#sources#syntax#min_keyword_length = 3let g:neocomplete#lock_buffer_name_pattern = '\*ku\*'' Define dictionary.let g:neocomplete#sources#dictionary#dictionaries = {    \ 'default' : '',    \ 'vimshell' : $HOME.'/.vimshell_hist',    \ 'scheme' : $HOME.'/.gosh_completions'        \ }' Define keyword.if !exists('g:neocomplete#keyword_patterns')    let g:neocomplete#keyword_patterns = {}endiflet g:neocomplete#keyword_patterns['default'] = '\h\w*'' Plugin key-mappings.inoremap     neocomplete#undo_completion()inoremap     neocomplete#complete_common_string()' Recommended key-mappings.' : close popup and save indent.inoremap =my_cr_function()function! s:my_cr_function()  return neocomplete#close_popup() . '\'  ' For no inserting key.  'return pumvisible() ? neocomplete#close_popup() : '\'endfunction' : completion.inoremap  pumvisible() ? '\' : '\'' , : close popup and delete backword char.inoremap neocomplete#smart_close_popup().'\'inoremap neocomplete#smart_close_popup().'\'inoremap  neocomplete#close_popup()inoremap  neocomplete#cancel_popup()' Close popup by .'inoremap pumvisible() ? neocomplete#close_popup() : '\'' For cursor moving in insert mode(Not recommended)'inoremap  neocomplete#close_popup() . '\''inoremap neocomplete#close_popup() . '\''inoremap    neocomplete#close_popup() . '\''inoremap  neocomplete#close_popup() . '\'' Or set this.'let g:neocomplete#enable_cursor_hold_i = 1' Or set this.'let g:neocomplete#enable_insert_char_pre = 1' AutoComplPop like behavior.'let g:neocomplete#enable_auto_select = 1' Shell like behavior(not recommended).'set completeopt+=longest'let g:neocomplete#enable_auto_select = 1'let g:neocomplete#disable_auto_complete = 1'inoremap  pumvisible() ? '\' : '\\'' Enable omni completion.autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSSautocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTagsautocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJSautocmd FileType python setlocal omnifunc=pythoncomplete#Completeautocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags' Enable heavy omni completion.if !exists('g:neocomplete#sources#omni#input_patterns')  let g:neocomplete#sources#omni#input_patterns = {}endif'let g:neocomplete#sources#omni#input_patterns.php = '[^. \t]->\h\w*\|\h\w*::''let g:neocomplete#sources#omni#input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)''let g:neocomplete#sources#omni#input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'' For perlomni.vim setting.' https://github.com/c9s/perlomni.vimlet g:neocomplete#sources#omni#input_patterns.perl = '\h\w*->\h\w*\|\h\w*::'imap (neocomplcache_snippets_force_expand)smap (neocomplcache_snippets_force_expand)imap (neocomplcache_snippets_force_jump)smap (neocomplcache_snippets_force_jump)' Enable omni completion.autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSSautocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTagsautocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJSautocmd FileType python setlocal omnifunc=pythoncomplete#Completeautocmd FileType c setlocal omnifunc=ccomplete#Completeif !exists('g:neocomplcache_omni_patterns')  let g:neocomplcache_omni_patterns = {}endiflet g:neocomplcache_omni_patterns.erlang = '[a-zA-Z]\|:'' SuperTab' let g:SuperTabDefultCompletionType='context'let g:SuperTabDefaultCompletionType = ''let g:SuperTabRetainCompletionType=2' ctrlpset wildignore+=*/tmp/*,*.so,*.o,*.a,*.obj,*.swp,*.zip,*.pyc,*.pyo,*.class,.DS_Store  ' MacOSX/Linux'let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$'' Keybindings for plugin togglennoremap :set invpaste paste?set pastetoggle=nmap :TagbarTogglenmap :NERDTreeTogglenmap :GundoTogglenmap :IndentGuidesTogglenmap   :nnoremap a :Acknnoremap v V`]'------------------' Useful Functions'------------------' easier navigation between split windowsnnoremap jnnoremap knnoremap hnnoremap l' When editing a file, always jump to the last cursor positionautocmd BufReadPost *      \ if ! exists('g:leave_my_cursor_position_alone') |      \     if line(''\'') > 0 && line (''\'') <= line('$') |      \         exe 'normal g'\'' |      \     endif |      \ endif' w!! to sudo & write a filecmap w!! %!sudo tee >/dev/null %' Quickly edit/reload the vimrc filenmap ev :e $MYVIMRCnmap sv :so $MYVIMRC' sublime key bindingsnmap >>nmap < >gv' for macvimif has('gui_running')    set go=aAce  ' remove toolbar    'set transparency=30    set guifont=Monaco:h13    set showtabline=2    set columns=140    set lines=40    noremap :tabprevious    noremap :tabnext    map 1gt    map 2gt    map 3gt    map 4gt    map 5gt    map 6gt    map 7gt    map 8gt    map 9gt    map :tablastendif''添加修改后的代码'''autocmd BufNewFile *.c,*.sh,*.java exec ':call SetTitle()''新建.cc,.java,.sh,'定义函数SetTitle,自动插入文件头func SetTitle()'如果文件类型为.sh文件if &filetype == 'sh'call setline(1, '\#!/bin/bash')call append(line('.'), '\#########################################################################')call append(line('.')+1, '\# Author: C')call append(line('.')+2, '\# Created Time: '.strftime('%c'))call append(line('.')+3, '\# File Name: '.expand('%'))call append(line('.')+4, '\# Description: ')call append(line('.')+5, '\#########################################################################')call append(line('.')+6, '')elsecall setline(1, '/*************************************************************************')call append(line('.'), ' Author: ')call append(line('.')+1, ' Created Time: '.strftime('%c'))call append(line('.')+2, ' File Name: '.expand('%'))call append(line('.')+3, ' Description: ')call append(line('.')+4, ' ************************************************************************/')call append(line('.')+5, '')endifendfunc

推荐信息