ÔÚLinuxϵͳÉÏʹÓÃVim¾ÙÐÐCÓïÑÔ¿ª·¢µÄÍƼöÉèÖÃ
ÔÚlinuxϵͳÉÏʹÓÃvim¾ÙÐÐcÓïÑÔ¿ª·¢µÄÍƼöÉèÖÃ
СÐò£º
ÔÚÅÌËã»ú¿ÆѧµÄѧϰºÍ¿ª·¢ÖУ¬CÓïÑÔÊÇÒ»ÃźÜÊÇÖ÷ÒªÇÒÆÕ±éʹÓõıà³ÌÓïÑÔ¡£¶øÔÚLinuxϵͳÉÏ£¬VimÊÇÒ»¿îÇ¿Ê¢µÄÎı¾±à¼Æ÷£¬Ëü¾ßÓÐÎÞа¡¢¿É¶¨Öƺ͸ßЧµÄÌص㡣±¾ÎĽ«ÏÈÈÝÔõÑùÉèÖÃVimÒÔÖª×ãCÓïÑÔ¿ª·¢µÄÐèÇó£¬ÓÅ»¯¿ª·¢ÌåÑéºÍÌá¸ßÊÂÇéЧÂÊ¡£
×°ÖÃVim
Ê×ÏÈ£¬È·±£ÄãµÄLinuxϵͳÒѾװÖÃÁËVim¡£¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁîÀ´¼ì²é£º
$ vim --version
µÇ¼ºó¸´ÖÆ
ÈôÊÇÏÔʾVimµÄ°æ±¾ÐÅÏ¢£¬ÔòÌåÏÖÒѾװÖá£ÈôÊÇûÓÐ×°Öã¬Ê¹ÓÃÒÔÏÂÏÂÁîÀ´×°Öãº
$ sudo apt-get update $ sudo apt-get install vim
µÇ¼ºó¸´ÖÆ
ÖÎÀíVimÉèÖÃÎļþ
VimµÄÉèÖÃÐÅÏ¢ÉúÑÄÔÚÓû§Ä¿Â¼ÏµÄ.vimrcÎļþÖС£ÈôÊDz»±£´æ¸ÃÎļþ£¬¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁÉ裺
Á¬Ã¦Ñ§Ï°¡°CÓïÑÔÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
$ touch ~/.vimrc
µÇ¼ºó¸´ÖÆ
È»ºó¿ÉÒÔʹÓÃÈκÎÎı¾±à¼Æ÷·¿ª²¢±à¼¸ÃÎļþ¡£
»ù±¾ÉèÖÃ
ÏÂÃæÊÇһЩ»ù±¾µÄÉèÖÃÑ¡Ï¿ÉÒÔ½«ÆäÌí¼Óµ½.vimrcÎļþÖУº
" ÉèÖÃËõ½øΪ4¸ö¿Õ¸ñ set tabstop=4 set shiftwidth=4 set expandtab " ÏÔʾÐкźÍ״̬À¸ set number set ruler " ÆôÓÃÓï·¨¸ßÁÁ syntax enable " ÆôÓÃ×Ô¶¯²¹È« set omnifunc=syntaxcomplete#Complete " ÉèÖÃÎļþ±àÂëΪUTF-8 set encoding=utf-8
µÇ¼ºó¸´ÖÆ
ÕâЩÉèÖûὫËõ½øÉèÖÃΪ4¸ö¿Õ¸ñ£¬ÏÔʾÐкźÍ״̬À¸£¬ÆôÓÃÓï·¨¸ßÁÁºÍ×Ô¶¯²¹È«¹¦Ð§£¬²¢½«Îļþ±àÂëÉèÖÃΪUTF-8¡£
×°Öòå¼þÖÎÀíÆ÷
VimµÄÇ¿Ê¢Ö®´¦ÔÚÓÚËüµÄ¿ÉÀ©Õ¹ÐÔ¡£Í¨¹ý×°Öòå¼þÖÎÀíÆ÷£¬¿ÉÒÔ¸üÀû±ãµØÖÎÀíºÍ×°ÖÃÖݪֲå¼þ¡£ÕâÀïÍƼöʹÓÃVundle²å¼þÖÎÀíÆ÷£¬¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî¾ÙÐÐ×°Öãº
$ git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
µÇ¼ºó¸´ÖÆ
È»ºóÔÚ.vimrcÎļþÖÐÌí¼ÓÒÔÏÂÉèÖÃÒÔÆôÓòå¼þÖÎÀíÆ÷£º
" Vundle²å¼þÖÎÀíÆ÷ÉèÖà set nocompatible filetype off set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " ÔÚ´Ë´¦Ìí¼ÓÄãËùÐèµÄ²å¼þ call vundle#end() filetype plugin indent on
µÇ¼ºó¸´ÖÆ
×°Öó£Óòå¼þ
ÏÖÔÚ¿ÉÒÔ×îÏÈ×°ÖÃһЩ³£ÓõIJå¼þÀ´ÔöÇ¿VimµÄ¹¦Ð§¡£ÒÔÏÂÊÇһЩÍƼöµÄ²å¼þ¼°Æä×°Öð취£º
a. NERDTree£ºÎļþ×ÊÔ´ÖÎÀíÆ÷²å¼þ£¬¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî¾ÙÐÐ×°Öãº
Plugin 'scrooloose/nerdtree'
µÇ¼ºó¸´ÖÆ
È»ºóÔÚ.vimrcÎļþÖÐÌí¼ÓÒÔÏ¿ì½Ý¼üÉèÖÃÒÔÀû±ãʹÓãº
" ʹÓÃF2¿ì½Ý¼ü·¿ª/¹Ø±ÕNERDTree map <F2> :NERDTreeToggle<CR>
µÇ¼ºó¸´ÖÆ
b. YouCompleteMe£º×Ô¶¯²¹È«²å¼þ£¬¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî¾ÙÐÐ×°Öã¬ÇëÈ·±£ÄúµÄϵͳÒѾװÖÃÁËCMakeºÍPythonµÄ¿ª·¢¿â£º
Plugin 'valloric/youcompleteme'
µÇ¼ºó¸´ÖÆ
È»ºóÔÚ.vimrcÎļþÖÐÌí¼ÓÒÔÏÂÉèÖÃÒÔÆôÓøòå¼þ£º
" YouCompleteMe²å¼þÉèÖà let g:ycm_autoclose_preview_window_after_completion=1 let g:ycm_min_num_of_chars_for_completion=2 let g:ycm_semantic_triggers=1 set completeopt=menuone,menu,longest map <F3> :YcmCompleter GoToDefinitionElseDeclaration<CR>
µÇ¼ºó¸´ÖÆ
c. tagbar£º´úÂëµ¼º½²å¼þ£¬¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî¾ÙÐÐ×°Öã¬ÇëÈ·±£ÄúµÄϵͳÒѾװÖÃÁËctags£º
Plugin 'majutsushi/tagbar'
µÇ¼ºó¸´ÖÆ
È»ºóÔÚ.vimrcÎļþÖÐÌí¼ÓÒÔÏ¿ì½Ý¼üÉèÖÃÒÔÀû±ãʹÓãº
" ʹÓÃF4¿ì½Ý¼ü·¿ª/¹Ø±Õtagbar map <F4> :TagbarToggle<CR>
µÇ¼ºó¸´ÖÆ
ÆäËû³£ÓÃÉèÖÃ
ÒÔÏÂÊÇһЩÆäËû³£ÓõÄÉèÖÃÑ¡Ï¿ÉÒÔƾ֤СÎÒ˽ÈËϲ»¶¾ÙÐÐÉèÖãº
" ÉèÖÃÎı¾ËÑË÷ʱºöÂÔ¾Þϸд set ignorecase set smartcase " ÆôÓÃÀ¨ºÅ×Ô¶¯²¹È« inoremap ( ()<LEFT> inoremap { {}<LEFT> inoremap [ []<LEFT> " ¹Ø±Õ×Ô¶¯±¸·ÝºÍ»»Ðзûת»» set nobackup set nowritebackup set noswapfile set fileformat=unix " ÉèÖôúÂëÕÛµþ set foldmethod=indent set foldlevel=1
µÇ¼ºó¸´ÖÆ
¿¢ÊÂÓ
ͨ¹ýÒÔÉϵÄÉèÖã¬ÄãµÄVim½«¾ß±¸Ò»Ð©Ç¿Ê¢µÄ¹¦Ð§ºÍ¹¤¾ß£¬¿ÉÒÔ¸ü±ã½ÝµØ¾ÙÐÐCÓïÑÔ¿ª·¢¡£ËäÈ»£¬ÕâЩֻÊÇһЩÍƼöµÄÉèÖÃÑ¡ÏÄã¿ÉÒÔƾ֤×Ô¼ºµÄÐèÇó¾ÙÐиöÐÔ»¯¶¨ÖÆ¡£Ï£ÍûÕâƪÎÄÕ¶ÔÄãÔÚLinuxÉÏʹÓÃVim¾ÙÐÐCÓïÑÔ¿ª·¢ÌṩÁËһЩ×ÊÖú¡£×£Äã±à³ÌÓä¿ì£¡
ÒÔÉϾÍÊÇÔÚLinuxϵͳÉÏʹÓÃVim¾ÙÐÐCÓïÑÔ¿ª·¢µÄÍƼöÉèÖõÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡