vimrc


set mouse=c

set nocompatible              " be iMproved, required

filetype off                  " required

set backspace=indent,eol,start

" 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' " 管理插件的插件

Plugin 'vim-scripts/indentpython.vim' " 自动缩进

Plugin 'Valloric/YouCompleteMe'  " 自动补全

"Plugin 'vim-syntastic/syntastic' " 保存时候的语法检查

Plugin 'nvie/vim-flake8' " flake8风格

Plugin 'altercation/vim-colors-solarized' "配色方案

Plugin 'tomasr/molokai' "配色方案

Plugin 'scrooloose/nerdtree' " 树型目录

Plugin 'Xuyuanp/nerdtree-git-plugin' " 为nerdtree添加git支持

Plugin 'jistr/vim-nerdtree-tabs' " 如果你想用tab键

Plugin 'Lokaltog/vim-powerline' " 美化状态栏,可以显示当前的虚拟环境、Git分支、正在编辑的文件等信息.

Plugin 'Yggdroot/indentLine' " 缩进指示线

Plugin 'jiangmiao/auto-pairs' " 自动补全括号和引号等

Plugin 'kien/ctrlp.vim' " 搜索插件,在vim normal模式下,按下ctrl+p,然后输入你要寻找的文件就行了

Plugin 'tpope/vim-fugitive' " git集成插件,可以在vim中运行git命令

Plugin 'scrooloose/nerdcommenter' " 批量注释插件

Plugin 'rkulla/pydiction.git' "python 自动补全

Plugin 'tmhedberg/SimpylFold' " 代码折叠

Plugin 'artur-shaik/vim-javacomplete2' "java 自动补全

Plugin 'Chiel92/vim-autoformat' "自动格式化工具

Plugin 'terryma/vim-multiple-cursors' "多光标编辑

Plugin 'fatih/vim-go' "go 自动补全插件

Plugin 'mattn/emmet-vim' "前端补全插件

Plugin 'godlygeek/tabular' "markdown插件

Plugin 'vim-scripts/auto_autoread.vim' " 自动重载插件

Plugin 'plasticboy/vim-markdown' "markdown插件

Plugin 'vim-scripts/bufexplorer.zip' " 查看历史文件

Plugin 'pangloss/vim-javascript'

Plugin 'mxw/vim-jsx'

Plugin 'justinj/vim-react-snippets' "vim-react-snippets:

Plugin 'SirVer/ultisnips' "Ultisnips

Plugin 'honza/vim-snippets' "Other sets of snippets (optional):

"All of your Plugins must be added before the following line

call vundle#end()            " required

filetype plugin indent on    " required

syntax on    "语法高亮

syntax enable

colorscheme molokai

if has('gui_running')

    set background=light

else

    set background=dark

endif

set clipboard=unnamedplus "将系统剪切板和vim 默认剪切板关联

set cursorline

set cursorcolumn

set number "显示行号

set nowrap    "不自动折行

set showmatch    "显示匹配的括号

set scrolloff=3        "距离顶部和底部3行"

set encoding=utf-8  "编码

set fenc=utf-8      "编码

set hlsearch        "搜索高亮

set tabstop=4  "tab宽度

set softtabstop=4

set shiftwidth=4 

set textwidth=79  "行最大宽度

set expandtab      "tab替换为空格键

set autoindent      "自动缩进

set fileformat=unix  "保存文件格式

set splitbelow

set splitright

set foldmethod=indent

set foldlevel=99

set showcmd

set ruler

set cmdheight=2

set ignorecase

set incsearch

set t_Co=256

set spell

"python自动补全 pydiction 的路径

let g:pydiction_location = '~/.vim/bundle/pydiction/complete-dict'

let g:pydiction_menu_height = 15

let g:ycm_global_ycm_extra_conf='~/.ycm_extra_conf.py'

let g:ycm_use_clangd = "Never"

let g:ycm_autoclose_preview_window_after_completion=1

let python_highlight_all=1

let NERDTreeIgnore=['\~$', '\.pyc$', '\.swp$']

let g:NERDTreeShowLineNumbers=1

let NERDTreeShowBookmarks=0

let g:nerdtree_tabs_open_on_console_startup=1 "共享nerdtree

let g:NERDTreeWinSize = 35

let g:SuperTabDefaultCompletionType = ''

let g:molokai_original = 1

let g:rehash256 = 1

" markdown相关配置

let g:vim_markdown_folding_disabled = 1  "不折叠显示,默认是折叠显示,看个人习惯

let g:vim_markdown_override_foldtext = 0

let g:vim_markdown_folding_level = 6    "可折叠的级数,对应md的标题级别

let g:vim_markdown_no_default_key_mappings = 1

let g:vim_markdown_emphasis_multiline = 0

set conceallevel=2

" 多光标操作配置

" 关闭插件默认映射

let g:multi_cursor_use_default_mapping = 0

" mapping

let g:multi_cursor_start_word_key      = '' " 选中一个

let g:multi_cursor_select_all_word_key = '' " 全选匹配的字符

let g:multi_cursor_start_key          = 'g'

let g:multi_cursor_select_all_key      = 'g'

let g:multi_cursor_next_key            = ''

let g:multi_cursor_prev_key            = '' " 回到上一个

let g:multi_cursor_skip_key            = '' " 跳过当前选中, 选中下一个

let g:multi_cursor_quit_key            = ''

" react 语法高亮

let g:jsx_ext_required = 0

nnoremap

nnoremap

nnoremap

nnoremap

nnoremap g :YcmCompleter GoToDefinitionElseDeclaration

" 代码折叠

nnoremap za

" 各个tab之间切换

nnoremap 1 1gt

nnoremap 2 2gt

nnoremap 3 3gt

nnoremap 4 4gt

nnoremap 5 5gt

nnoremap 6 6gt

nnoremap 7 7gt

nnoremap 8 8gt

nnoremap 9 9gt

"自动运行

map :call CompileRunGcc()

map :NERDTreeToggle

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 python %"

    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

autocmd vimenter * NERDTree

autocmd vimenter * if !argc()|NERDTree|endif

autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif

function! TabPos_ActivateBuffer(num)

    let s:count = a:num

    exe "tabfirst"

    exe "tabnext" s:count

endfunction

"显示标签页的序号

hi SelectTabLine term=Bold cterm=Bold gui=Bold ctermbg=None

hi SelectPageNum cterm=None ctermfg=Red ctermbg=None

hi SelectWindowsNum cterm=None ctermfg=DarkCyan ctermbg=None

hi NormalTabLine cterm=Underline ctermfg=Black ctermbg=LightGray

hi NormalPageNum cterm=Underline ctermfg=DarkRed ctermbg=LightGray

hi NormalWindowsNum cterm=Underline ctermfg=DarkMagenta ctermbg=LightGray

function! MyTabLabel(n, select)

    let label = ''

    let buflist = tabpagebuflist(a:n)

    for bufnr in buflist

        if getbufvar(bufnr, "&modified")

            let label = '+'

            break

        endif

    endfor

    let winnr = tabpagewinnr(a:n)

    let name = bufname(buflist[winnr - 1])

    if name == ''

        "为没有名字的文档设置个名字

        if &buftype == 'quickfix'

            let name = '[Quickfix List]'

        else

            let name = '[No Name]'

        endif

    else

        "只取文件名

        let name = fnamemodify(name, ':t')

    endif

    let label .= name

    return label

endfunction

" 展示标签的编码

function! MyTabLine()

    let s = ''

    for i in range(tabpagenr('$'))

        " 选择高亮

        let hlTab = ''

        let select = 0

        if i + 1 == tabpagenr()

            let hlTab = '%#SelectTabLine#'

            " 设置标签页号 (用于鼠标点击)

            let s .= hlTab . "[%#SelectPageNum#%T" . (i + 1) . hlTab

            let select = 1

        else

            let hlTab = '%#NormalTabLine#'

            " 设置标签页号 (用于鼠标点击)

            let s .= hlTab . "[%#NormalPageNum#%T" . (i + 1) . hlTab

        endif

        " MyTabLabel() 提供标签

        let s .= ' %<%{MyTabLabel(' . (i + 1) . ', ' . select . ')} '

        "追加窗口数量

        let wincount = tabpagewinnr(i + 1, '$')

        if wincount > 1

            if select == 1

                let s .= "%#SelectWindowsNum#" . wincount

            else

                let s .= "%#NormalWindowsNum#" . wincount

            endif

        endif

        let s .= hlTab . "]"

    endfor

    " 最后一个标签页之后用 TabLineFill 填充并复位标签页号

    let s .= '%#TabLineFill#%T'

    " 右对齐用于关闭当前标签页的标签

    if tabpagenr('$') > 1

        let s .= '%=%#TabLine#%999XX'

    endif

    return s

endfunction

set tabline=%!MyTabLine()

autocmd FileType java setlocal omnifunc=javacomplete#Complete

autocmd FileType java set completefunc=javacomplete#CompleteParamsInf

"highlight CursorLine cterm=none ctermbg=1

"highlight CursorColumn cterm=none ctermbg=1

你可能感兴趣的:(vimrc)