vim安裝與外掛配置
vim安裝與外掛配置
vim安裝
sudo apt-get install vim
vim配置
這裡借鑑 https://blog.csdn.net/t_t233333333/article/details/104752066 的配置
set number "設定行號" syntax on "開啟高亮" set showcmd "在底部顯示命令" set mouse=a "支援使用滑鼠" set encoding=utf-8 "使用utf-8編碼" set t_Co=256 "配色方案為256" filetype indent on "自動檢查檔案型別並載入對應的縮排" set autoindent "按下回車後下一行的縮排和上一行保持一致 set tabstop=4 "縮排為4" set shiftwidth=4 "使用>>/<</==進行縮排設定的空格數" set cursorline "游標所在行高亮" set textwidth=80 "設定一行顯示多少字元" set wrap "自動折行" set linebreak "遇到符號時才會自動折行" set wrapmargin=2 "指定折行處與編輯視窗的右邊緣之間空出的字元數" set scrolloff=5 "垂直滾動時,游標距離頂部/底部的位置(單位:行)" set laststatus=2 "是否顯示狀態列。0 表示不顯示,1 表示只在多視窗時顯示,2 表示顯示" set ruler "在狀態列顯示游標的當前位置(位於哪一行哪一列)" set showmatch "游標遇到圓括號、方括號、大括號時,自動高亮對應的另一個圓括號、方括號和大括號 set hlsearch "搜尋時,高亮顯示匹配結果 set incsearch "輸入搜尋模式時,每輸入一個字元,就自動跳到第一個匹配的結果 set spell spelllang=en_us "開啟英語單詞的拼寫檢查 set noerrorbells "出錯時,不要發出響聲 set visualbell "出錯時,發出視覺提示,通常是螢幕閃爍 set history=1000 "Vim 需要記住多少次歷史操作 set autoread "開啟檔案監視。如果在編輯過程中檔案發生外部改變(比如被別的編輯器編輯了),就會發出提示
安裝Vundle外掛管理器
建立~/.vimrc
檔案,在裡面寫上:
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
call vundle#end()
filetype plugin indent on
以後需要新增其他外掛就在call vundle#begin()
和call vundle#end()
之間插入就行。
安裝YouCompleteMe程式碼補全
在.vimrc
裡新增這一行:Plugin 'Valloric/YouCompleteMe'
開啟vim,輸入:PluginInstall
進入~/.vim/bundle/YouCompleMe
輸入:git submodule update --init --recursive
輸入./install.py --clang-completer
安裝
在.vimrc
最後一行加入:let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/.ycm_extra_conf.py'
提示沒有安裝cmake
sudo apt-get install cmake
提示Python headers are missing in /usr/include/python3.8
sudo apt-get install python3.8-dev
設定行號縮排
在/etc/vim/vimrc
裡新增下面幾行:
set number
set autoindent
set ts=4
安裝AutoPairs
在.vimrc
裡新增這一行:Plugin 'jiangmiao/auto-pairs'
開啟vim,輸入:PluginInstall
出現一次縮排兩個tab的情況
在/etc/vim/vimrc
裡新增下面一行:
set sw=4
安裝目錄樹外掛
在.vimrc
裡新增這一行:Plugin 'scrooloose/nerdtree'
開啟vim,輸入:PluginInstall
使用方法::NERDTree
或者在.vimrc
中新增一行:nmap <F2> :NERDTree <CR>
,以後就可以使用F2打開了
修改配色主題
把配色方案放到~/.vim/colors
中,在.vimrc
裡新增這幾行:
syntax on
syntax enable
set t_Co=256
colorscheme 你的配色主題
這篇方案推薦還是不錯的:https://zhuanlan.zhihu.com/p/58188561
我的個人選擇是:https://github.com/nightsense/stellarized