我的vimrc

set nocompatible
set number
filetype off
set history=1000
colorscheme jellybeans
syntax on
set autoindent
"set smartindent
set tabstop=4
set shiftwidth=4
set showmatch
set noexpandtab
set guioptions-=T
set backspace=2
set ruler
set incsearch
set nobackup
set nowrap
set viminfo='1000
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set lines=35 columns=100
"以上设置部分

set rtp+=$HOME\.vim\bundle\Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'godlygeek/tabular'
Plugin 'plasticboy/vim-markdown'
Plugin 'joker1007/vim-markdown-quote-syntax'
Plugin 'iamcco/markdown-preview.vim'
call vundle#end()
filetype plugin indent on
" 以上vundle
let g:vim_markdown_folding_disabled = 1
set conceallevel=2
let g:vim_markdown_math = 1
nmap <silent> <F9> <Plug>MarkdownPreview
nmap <silent> <F10> <Plug>MarkdownPreviewStop

map <F9> :call Compile()<CR>
map <F10> :call Run()<CR>
map <F5> :call RunGdb()<CR>
func! Compile()
    if &filetype == 'cpp'
        exec "!g++ % -o %< -m32 -Wall -Wl,--stack=102400000 -fdiagnostics-color=always"
        exec "redraw!"  
    endif
endfunc
func! Run()
    if &filetype == 'cpp'
        exec "!%<"
        exec "redraw!"  
    endif
endfunc
func! RunGdb()
    :call Compile()
    exec "!gdb32 %<"
    exec "redraw!"  
endfunc
"以上运行&调试

inoremap ( ()<LEFT>
inoremap [ []<LEFT>
inoremap { {}<LEFT>
"以上自动补全

map <S-u> <C-r>
"把U设为重做
map <C-s> <Esc>:w<cr>
"更熟悉的保存方法
noremap x "_x
noremap X "_dd
"让x和X成为真正的删除字符/删除一行
noremap s "_s
noremap S "_S
"让s和S成为真正的删除+插入字符/一行

func! Remdc(char)
    if getline('.')[col('.') - 1] == a:char
        return "\<Right>"
    else
        return a:char
    end if
endfunc
func! Remdc2(char)
    if getline('.')[col('.') - 1] == a:char
        return "\<Right>"
    else
        return a:char . a:char . "\<Left>"
    endif
endfunc
inoremap ) <c-r>=Remdc(')')<CR>
inoremap ] <c-r>=Remdc(']')<CR>
inoremap } <c-r>=Remdc('}')<CR>
inoremap ' <c-r>=Remdc2("'")<CR>
inoremap " <c-r>=Remdc2('"')<CR>
"以上避免重复括号,同时处理了引号的自动补全

func! Autonl()
    if getline('.')[col('.') - 2] == '{' && getline('.')[col('.') - 1] == '}'
        return "\<CR>\<CR>\<UP>\<TAB>"
    elseif getline('.')[col('.') - 2] == ')'
        return "\<CR>\<TAB>"
    else
        return "\<CR>"
    endif
endfunc
inoremap <CR> <c-r>=Autonl()<CR>
inoremap <S-CR> <c-r>=Autonl()<CR>
"以上自动换行

func! Rempr()
    if getline('.')[col('.') - 2] == '{' && getline('.')[col('.') - 1] == '}'
        return "\<Right>\<BS>\<BS>"
    elseif getline('.')[col('.') - 2] == '(' && getline('.')[col('.') - 1] == ')'
        return "\<Right>\<BS>\<BS>"
    elseif getline('.')[col('.') - 2] == '[' && getline('.')[col('.') - 1] == ']'
        return "\<Right>\<BS>\<BS>"
    elseif getline('.')[col('.') - 2] == '"' && getline('.')[col('.') - 1] == '"'
        return "\<Right>\<BS>\<BS>"
    elseif getline('.')[col('.') - 2] == "'" && getline('.')[col('.') - 1] == "'"
        return "\<Right>\<BS>\<BS>"
    else
        return "\<BS>"
    endif
endfunc
inoremap <BS> <c-r>=Rempr()<CR>
"以上自动删除匹配

/plasticboy/vim-markdown:

  • zR:打开所有标题

  • zM:折叠所有标题

  • zA:打开当前标题

  • zC:折叠当前标题

posted @ 2018-09-13 09:11 pechpo 阅读(...) 评论(...) 编辑 收藏