最适合自己的vim高级完美配置

前提:
vim插件中最主要的就是vundle了,vundle用来管理vim的其它插件。
项目地址https://github.com/VundleVim/Vundle.vim
首先看~/.vim/bundle目录是否存在,不存在则创建目录:

cd ~
mkdir .vim
cd .vim
mkdir bundle

然后进入到bundle目录下,下载源码:

cd ~/.vim/bundle/
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

下载好后,将下列配置放在.vimrc文件的开头:

set nocompatible              " be iMproved, required
filetype off                  " required
 
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
 
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
 
" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required

如果想下载某个插件,比如自动缩进indentpython.vim插件,需要将

Plugin 'vim-scripts/indentpython.vim'

置于call vundle#begin()和call vundle#end()之间,保存配置后在vim中执行

:PluginInstall

即可以自动下载indentpython.vim插件了。

完整的配置:

"""""""""""""""""""""""""""""""""""""
"Vundle
"""""""""""""""""""""""""""""""""""""
set nocompatible
filetype off

"set the runtime path to include Vundle and initialaze
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
"let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
""""""""""""""""""""""""""""
"代码补全 snipMate
Plugin 'MarcWeber/vim-addon-mw-utils'
Plugin 'tomtom/tlib_vim'
Plugin 'garbas/vim-snipmate'
"Optional:
Plugin 'honza/vim-snippets'
""""""""""""""""""""""""""""
"缩进提示线
Plugin 'Yggdroot/indentLine'
""""""""""""""""""""""""""""
"编程提示 jedi-vim
"Plugin 'davidhalter/jedi-vim'
""""""""""""""""""""""""""""
"自动补全括号和引号 auto-pairs
Plugin 'jiangmiao/auto-pairs'
""""""""""""""""""""""""""""
"solarized配色方案
"Plugin 'altercation/vim-colors-solarized'
"Plugin 'rakr/vim-one'
"Plugin 'vim-scripts/peaksea'
Plugin 'morhetz/gruvbox'
syntax enable
if has('gui_running')
    set background=light
else
    set background=dark
	"set t_Co=256
	"set term=xterm-256color
	set termguicolors
endif
"let g:solarized_termtrans=1
"let g:solarized_termcolors=256
"let g:solarized_termctrans=1
"let g:airline_theme='one'
"colorscheme solarized
"colorscheme desert
colorscheme gruvbox
"colorscheme peaksea 
""""""""""""""""""""""""""""
"nerdtree树形目录
Plugin 'scrooloose/nerdtree'
"Ctrl+n可以开启目录
map <C-n> :NERDTreeToggle<CR>
"设置忽略.pyc文件
let NERDTreeIgnore=['\~$', '\.pyc$', '\.swp$']
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
"let NERDTreeMinimalUI = 1
"let NERDTreeDirArrows = 1
"用tab键操作
Plugin 'jistr/vim-nerdtree-tabs'
""""""""""""""""""""""""""""
"美化状态栏
Plugin 'Lokaltog/vim-powerline'
""""""""""""""""""""""""""""
"flake8代码风格检查
"Plugin 'nvie/vim-flake8'
Plugin 'tell-k/vim-autopep8'
autocmd FileType python noremap <buffer> <F8> :call Autopep8()<CR>
""""""""""""""""""""""""""""
"自动保存
"Plugin 'vim-scripts/vim-auto-save'
"let g:auto_save = 1
"let g:auto_save_events = ["InsertLeave", "TextChanged", "TextChangedI", "CursorHoldI", "CompleteDone"]
""""""""""""""""""""""""""""
"All of your Plugins must be added before the following line
call vundle#end()
filetype plugin indent on


"""""""""""""""""""""""""""""""""""""
"my config
"""""""""""""""""""""""""""""""""""""
set nu
"syntax on
set tabstop=4
set softtabstop=4
set shiftwidth=4
set autoindent
set showmatch
set completeopt=preview,menu
set autowriteall
"set autoread

"当代码行数很多的时候,代码折叠是很必须的
"使用zc按键来创建折叠,使用za来打开或者关闭折叠。
"za经常会误输入,可以用空格键来替代za
set foldmethod=indent
set foldlevel=99
nnoremap <space> za

map  I#<Esc>
map  0x
map  I//<Esc>

map [1;5C <Esc>:bn
map [1;5D <Esc>:bp

ab my163 syd2285734649@163.com
ab myqq 2285734649@qq.com

set fileencodings=utf-8,chinese,latin1
set termencoding=utf-8
set encoding=utf-8

"每过十秒自动保存文件
"set updatetime=10000
"autocmd CursorHoldI * silent w

"""""""""""""""""""""""""""""""""""""
"Quickly Run
"""""""""""""""""""""""""""""""""""""
map <F5> :call CompileRunGcc()<CR>
func! CompileRunGcc()
    exec "w"
    if &filetype == 'c'
        exec "!g++ % -o %<"
        exec "!time ./%<"
    elseif &filetype == 'cpp'
        exec "!g++ % -o %<"
        exec "!time ./%<"
    elseif &filetype == 'java'
        exec "!javac %"
        exec "!time java %<"
    elseif &filetype == 'sh'
        :!time bash %
    elseif &filetype == 'python'
        exec "!time python3 %"
    elseif &filetype == 'html'
        exec "!firefox %&"
    elseif &filetype == 'go'
        exec "!time go run %"
    elseif &filetype == 'mkd'
        exec "!~/.vim/markdown.pl % > %.html &"
        exec "!firefox %.html &"
    endif
endfunc

"""""""""""""""""""""""""""""""""""""
"Syntastic
"""""""""""""""""""""""""""""""""""""
execute pathogen#infect()
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*

let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_python_checkers = ['pylint']

**可能的错误: ** Cannot find color scheme 'solarized' 或者 Cannot find color scheme 'one'或者是其他。

解决方案:
没有~/.vim/colors/就创建。

cp ~/.vim/bundle/vim-colors-solarized/colors/solarized.vim ~/.vim/colors/

参考文章:
https://www.cnblogs.com/linxiyue/p/7834817.html
https://www.zhihu.com/question/20271508
https://www.cnblogs.com/linxiyue/p/7834817.html
https://zhuanlan.zhihu.com/p/58188561?from_voters_page=true

  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值