vim安裝與插件配置

vim安裝與插件配置

vim安裝

sudo apt-get install vim

vim配置

這裏借鑑 https://blog.csdn.net/t_t233333333/article/details/104752066 的配置python

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文件,在裏面寫上:git

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()之間插入就行。github

安裝YouCompleteMe代碼補全

.vimrc裏添加這一行:Plugin 'Valloric/YouCompleteMe'vim

打開vim,輸入:PluginInstall編輯器

進入~/.vim/bundle/YouCompleMe輸入:git submodule update --init --recursive編碼

輸入./install.py --clang-completer安裝.net

.vimrc最後一行加入:let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/.ycm_extra_conf.py'插件

提示沒有安裝cmake

sudo apt-get install cmakecode

提示Python headers are missing in /usr/include/python3.8

sudo apt-get install python3.8-devblog

設置行號縮進

/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

Now, enjoy vim!

相關文章
相關標籤/搜索