我的vim配置-2018-5-25

vim 基本配置

基本配置文件

"author: pjzero
"email: pjwhusir@gmail.com

" let backspace can delete
set nocompatible
set backspace=indent,eol,start

" Plugin
call plug#begin('~/.vim/plugged')
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'Valloric/YouCompleteMe'
Plug 'scrooloose/nerdtree'
Plug 'flazz/vim-colorschemes'
Plug 'jiangmiao/auto-pairs'
Plug 'ntpeters/vim-better-whitespace'
Plug 'tpope/vim-surround'
Plug 'vim-airline/vim-airline'
Plug 'w0rp/ale'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'scrooloose/nerdcommenter'
Plug 'tmhedberg/SimpylFold'
call plug#end()

" ==============
" map keys
" ==============
let mapleader = ";"
nmap <leader>w :w!<cr>
nmap <leader>q :q<cr>
nmap <leader>wq :wq<cr>
nmap <leader>tn :tabnew<cr>
nmap <leader>te :tabedit
nmap <leader>tc :tabclose<cr>
" =>Remove unwanted spaces
map <leader>c :%s/\s\+$//<cr>

" =>Removes highlight of your last search
noremap <C-h> :nohl<cr>
vnoremap <C-h> :nohl<cr>
inoremap <C-h> :nohl<cr>

" => code format using google/yapf
autocmd FileType python nnoremap <leader>= :0,$!yapf<CR>


" ==============
" end of map keys
" ==============


" ==============
" plug config
" ==============

" =>nerdtree config
map <C-n> :NERDTreeToggle<cr>
" + 当不带参数打开Vim时自动加载项目树
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
" + 当所有文件关闭时关闭项目树窗格
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
" + 不显示这些文件
let NERDTreeIgnore=['\.pyc$', '\~$', 'node_modules'] "ignore files in NERDTree
" + 不显示项目树上额外的信息,例如帮助、提示什么的
let NERDTreeMinimalUI=1

" =>vim-fzf
nnoremap <silent> <C-p> :Files<cr>

" => NERD Commenter
" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
" Use compact syntax for prettified multi-line comments
let g:NERDCompactSexyComs = 1
" Align line-wise comment delimiters flush left instead of following code indentation
let g:NERDDefaultAlign = 'left'
" Add your own custom formats or override the defaults
let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } }
" Allow commenting and inverting empty lines (useful when commenting a region)
let g:NERDCommentEmptyLines = 1
" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1

" => SimpleFold
set foldmethod=indent
au BufWinLeave * silent mkview  " 保存文件的折叠状态
au BufRead * silent loadview    " 恢复文件的折叠状态
nnoremap <space> za             " 用空格来切换折叠状态

" => ale
let g:ale_sign_column_always = 1
let g:ale_sign_error = '>>'
let g:ale_sign_warning = '--'
let g:ale_lint_on_text_changed = 'never'
" let g:ale_lint_on_enter = 0

" =================
" end of plug
" =================


" vim 命令行模式自动补全
set wildmenu

" tab line
set showtabline=1

" show matching bracets when text indicator is over them
set showmatch

" [color scheme]
set background=light
set t_Co=256
let g:solarized_termcolors = 256
let g:solarized_visibility = "high"
let g:solarized_contrast = "high"
colorscheme solarized

" syntax highlight on
syntax on
set encoding=utf-8
set guifont=DejaVu\ Sans\ Mono\ 10

"FileType support
set filetype=on
filetype plugin indent on

" Highlight the screen line of the cursor with CursorLine
set cursorline

" Showing line numbers and length
set number  " show line numbers
set tw=79   " width of document (used by gd)
set colorcolumn=80

" Useful settings
set history=700
set undolevels=700

" Real programmers don't use TABs but spaces
set tabstop=4
set softtabstop=4
set shiftwidth=4
set shiftround
set smarttab
" set expandtab

" Make search case insensitive
set hlsearch
set incsearch   " 实时搜索功能开启
set ignorecase   " 搜索时忽略大小写
set smartcase

" Disable stupid backup and swap files - they trigger too many events
" for file system watchers
set nobackup
set nowritebackup
set noswapfile

安装 vim-plug

curl -fLo ~/.vim/autoload/plug.vim --create-dirs  https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

安装youcompleteme

sudo pacman -S cmake
git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/plugged/YouCompleteMe
cd ~/.vim/bundle/YouCompleteMe
./install.py --clang-completer

安装其他插件


  • 找到你要的插件
  • 去配置文件配置好

Plugin ‘somebody/someplugin’

  • 打开vim

  • 输入安装命令
    :PlugInstall
  • 如果报错了

    The ycmd server SHUT DOWN (restart with ‘:YcmRestartServer’). YCM…CM before using it. Follow the instructions in the documentation.

    cd ~/.vim/plugged/YouCompleteMe
    # 或者
    cd ~/.vim/bundle/YouCompleteMe
    ./install.py --clang-completer
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值