vim 配置文件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vim 配置文件相关的知识,希望对你有一定的参考价值。

call pathogen#infect()    
call pathogen#helptags()
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_jump = 1
set number
set encoding=utf-8
"自动换行
"set textwidth=80
"自动折行
set wrap
nnoremap <C-J> <C-W><C-J> "Ctrl-j to move down a split  
nnoremap <C-K> <C-W><C-K> "Ctrl-k to move up a split  
nnoremap <C-L> <C-W><C-L> "Ctrl-l to move    right a split  
nnoremap <C-H> <C-W><C-H> "Ctrl-h to move left a split
"将用ctrl+w hjkl的在窗口间跳转映射为ctrl+hjkl跳转窗口
set relativenumber "使vim对当前行显示绝对行号,对其他行显示相对行号
set number"显示行号
set shortmess =alt  "不显示乌干达
syntax enable
syntax on "语法高亮
set mouse=a "设置鼠标可用
set mouse=v "设置鼠标可右键
set mouse=i
set nocp "设置兼容
set nowrap "设置自动换行
nnoremap <F6>  <Esc>:w<CR>:!g++ -std=c++11 % -o /tmp/a.out &&/tmp/a.out<CR>"运行
nnoremap <F7>  <Esc>:w<CR>:!g++ -std=c++11 % -o /tmp/a.out && /tmp/a.out><CR>"编译
"让它可以在新窗口中显示出来
"括号自动补全
""inoremap ( ()<LEFT>
""inoremap [ []<LEFT>
""inoremap { {}<LEFT>
""inoremap " ""<LEFT>
""inoremap ‘ ‘‘<LEFT>
""inoremap < <><LEFT>
set backspace=indent,eol,start
set autoindent "开启新行时自动缩进
set smartindent "新行时自动对齐
set ruler"显示标尺
set splitbelow
set splitright
set nocompatible"去掉vi一致性
set cindent"开启c语法检查
set cursorline"光标行颜色设置
set cursorcolumn"光标元素设置
hi CursorLine cterm=NONE Ctermbg=darkgray ctermfg=NONE
hi CursorColumn cterm=NONE ctermbg=darkgray ctermfg=NONE
set laststatus=2 "显示状态栏
set si "自动缩进
set showmatch "代码匹配
set expandtab 
set shiftwidth=4
set tabstop=4 "设置tab和缩进空格数
set hls "检索时高亮显示匹配项
imap { {}<ESC>i<CR><ESC>O<TAB><BackSpace>

"兼容pep8标准,防止跟他人在github上冲突
set tabstop=4
set softtabstop=4
set shiftwidth=4
set textwidth=80"可以设置自动换行,只在英文下有效
set expandtab
set autoindent
set fileformat=unix
set statusline=format
set statusline=[路径=%F]/[修改过=%m]/[只读%r]/%h[预览窗口=%w]/[FORMAT=%{&ff}]/[缓冲区文件类型=%Y]/[ASCII=/%03.3b]/[HEX=/%02.2B]/[POS=%04l,%04v][%p%%]/[缓冲区行数=%L]/时间:%-16{strftime(\"%Y-%m-%d\ %H:%M\")}"
"状态栏设置

hi StatusLine ctermfg=darkred ctermbg=blue
hi StaTusLineNC ctermfg=blue ctermbg=black
"colorscheme darkblue "可以在/usr/share/vim/vim74/colors/里查看可选

set nocompatible              " be iMproved, required
filetype on
filetype    plugin on " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin(‘~/some/path/here‘)

" let Vundle manage Vundle, required
Plugin ‘VundleVim/Vundle.vim‘
"这里是安装状态栏的注释
Plugin ‘bling/vim-airline‘
"这里是安装左边的文件夹栏
Plugin ‘Xuyuanp/nerdtree-git-plugin‘
Plugin ‘tpope/vim-fugitive‘
Plugin ‘git://git.wincent.com/command-t.git‘
Plugin ‘Valloric/YouCompleteMe‘
Plugin ‘vim-ctrlspace/vim-ctrlspace‘
"这里是安装目录树
Plugin ‘scrooloose/nerdtree‘
autocmd VimEnter * NERDTree
let NERDTreeShowBookmarks=2
set hidden
"The NERD tree
"F3触发,设置宽度为30,显示书签
map <F3> :NERDTreeToggle<CR>
let NERDTreeWinSize = 30
let NERDTreeShowBookmarks = 1
"高亮当前行
let NERDTreeHighlightCursorline = 1
"从NERDTree打开文件后自动关闭NERDTree
let NERDTreeQuitOnOpen = 1
"显示隐藏文件
let g:NERDTreeShowHidden = 1
"忽略特定文件和目录
let NERDTreeIgnore=[ ‘\.pyc$‘, ‘\.pyo$‘, ‘\.py\$class$‘, ‘\.obj$‘,
            \ ‘\.o$‘, ‘\.so$‘, ‘\.egg$‘, ‘^\.git$‘, ‘__pycache__‘, ‘\.DS_Store‘ ]
"显示行号
let NERDTreeShowLineNumbers = 1
let NERDTreeAutoCenter = 1

map <F3> :NERDTreeToggle<CR>
Bundle ‘Raimondi/delimitMate‘
filetype plugin indent on    " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList       - lists configured plugins
" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
"

let g:ycm_global_ycm_extra_conf=‘~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py‘
"这里是添加头文件的事件回调
function! AutoSetShFileHead()
    if expand("%:e") =="sh"
        call append(1,"\#!/bin/bash")
    endif

    normal G
    normal o
endfunc

function! AutoSetPyFileHead()
    if expand("%:e") == "py"
        call append(1,"\#!usr/bin/python3")
        call append(2,"\# encoding:utf-8")
    endif

    normal G
    normal o
endfunc
func! SetHeader()
    if expand("%:e") == "cpp"
        call setline(1,"#include<iostream>")
        call setline(2,"using namespace std;")
        call setline(3,"int main")
        call setline(4,"{")
        call setline(5,"}")
    endif
    normal G
    normal O
endfunc
autocmd BufNewFile *.sh exec ":call AutoSetShFileHead()"
autocmd BufNewFile *.py exec ":call AutoSetPyFileHead()"
autocmd BufNewFile *.cpp exec ":call SetHeader()"
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
Plugin ‘altercation/vim-colors-solarized‘
Plugin ‘tomasr/molokai‘
Plugin ‘vim-scripts/phd‘
Plugin ‘Lokaltog/vim-powerline‘
Plugin ‘octol/vim-cpp-enhanced-highlight‘
Plugin ‘nathanaelkane/vim-indent-guides‘
" 随 vim 自启动
let g:indent_guides_enable_on_vim_startup=1
" 从第二层开始可视化显示缩进
let g:indent_guides_start_level=2
" 色块宽度
let g:indent_guides_guide_size=1
" 快捷键 i 开/关缩进可视化
:nmap <silent> <Leader>i <Plug>IndentGuidesToggle
Plugin ‘derekwyatt/vim-fswitch‘
Plugin ‘kshenoy/vim-signature‘
Plugin ‘vim-scripts/BOOKMARKS--Mark-and-Highlight-Full-Lines‘
Plugin ‘majutsushi/tagbar‘
Plugin ‘vim-scripts/indexer.tar.gz‘
Plugin ‘vim-scripts/DfrankUtil‘
Plugin ‘vim-scripts/vimprj‘
Plugin ‘dyng/ctrlsf.vim‘
Plugin ‘terryma/vim-multiple-cursors‘
Plugin ‘scrooloose/nerdcommenter‘
Plugin ‘vim-scripts/DrawIt‘
Plugin ‘SirVer/ultisnips‘
Plugin ‘derekwyatt/vim-protodef‘
Plugin ‘fholgado/minibufexpl.vim‘
Plugin ‘gcmt/wildfire.vim‘
Plugin ‘sjl/gundo.vim‘
Plugin ‘Lokaltog/vim-easymotion‘
Plugin ‘suan/vim-instant-markdown‘
Plugin ‘lilydjwg/fcitx.vim‘
call vundle#end()
filetype plugin indent on
"这里是haskell的插件库
let g:haskell_enable_quantification=1 "to enable highlighting of ‘forall‘
let g:haskell_enable_recursivedo=1 "to enable highlight of ‘mdo‘ and ‘rec‘
let g:haskell_enable_arrowsyntax=1 "to enable highlight of ‘proc‘
let g:haskell_enable_pattern_synonyms=1 "to enable highlighting of ‘pattern‘
let g:haskell_enable_typeroles=1 "to enable highlighting of type roles
let g:haskell_enable_static_pointers=1 "to enable highlighting of ‘static‘
let g:haskell_enable_backpack=1 "to enable highlighting of backpack keywords

 

以上是关于vim 配置文件的主要内容,如果未能解决你的问题,请参考以下文章

从零开始配置vim(27)——代码片段

vim代码片段插件ultisnips的使用

latex在vim中的代码片段

VIM 代码片段插件 ultisnips 使用教程

Sublime text3最全快捷键清单

VSCode自定义代码片段11——vue路由的配置