kkogoro

我的VIM配置文件
我的VIM配置文件适合带入考场的syntax enable syntax on set tabstop=4 se...
扫描右侧二维码阅读全文
23
2018/10

我的VIM配置文件

我的VIM配置文件

适合带入考场的

syntax enable
syntax on

set tabstop=4
set shiftwidth=4

set autoindent
set smartindent

set number
set showcmd

set showmatch
set matchtime=1 " 匹配括号高亮的时间(单位是十分之一秒)

功能多一点的

星号前的是我的gVim自带的, 折叠用’行数+zf’(共折叠n + 1行), 解折叠用zd 或zD(全解放)

set laststatus=2                " make the last line where the status is two lines deep so you can see status always
set backspace=indent,eol,start  " make that backspace key work the way it should
set background=dark             " Use colours that work well on a dark background (Console is usually black)
set showmode                    " show the current mode
set clipboard=unnamed           " set clipboard to unnamed to access the system clipboard under windows

" Show EOL type and last modified timestamp, right after the filename
set statusline=%<%F%h%m%r\ [%{&ff}]\ (%{strftime(\"%H:%M\ %d/%m/%Y\",getftime(expand(\"%:p\")))})%=%l,%c%V\ %P

" Only do this part when compiled with support for autocommands.
if has("autocmd")
    "Set UTF-8 as the default encoding for commit messages
    autocmd BufReadPre COMMIT_EDITMSG,MERGE_MSG,git-rebase-todo setlocal fileencodings=utf-8

    "Remember the positions in files with some git-specific exceptions"
    autocmd BufReadPost *
      \ if line("'\"") > 0 && line("'\"") <= line("$")
      \           && expand("%") !~ "COMMIT_EDITMSG"
      \           && expand("%") !~ "MERGE_EDITMSG"
      \           && expand("%") !~ "ADD_EDIT.patch"
      \           && expand("%") !~ "addp-hunk-edit.diff"
      \           && expand("%") !~ "git-rebase-todo" |
      \   exe "normal g`\"" |
      \ endif

      autocmd BufNewFile,BufRead *.patch set filetype=diff
      autocmd BufNewFile,BufRead *.diff set filetype=diff

      autocmd Syntax diff      
      \ highlight WhiteSpaceEOL ctermbg=red |
      \ match WhiteSpaceEOL /\(^+.*\)\@<=\s\+$/

      autocmd Syntax gitcommit setlocal textwidth=74
endif " has("autocmd")
"*********************************************************************************
syntax enable
syntax on

set tabstop=4
set shiftwidth=4

set autoindent
set smartindent

set number
set showcmd

set showmatch
set matchtime=1 " 匹配括号高亮的时间(单位是十分之一秒) 

set novisualbell
"set cursorline

colorscheme evening

set foldenable      " 允许折叠  
set foldmethod=manual   " 手动折叠  

set nocompatible  "去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限  

" 显示中文帮助
if version >= 603
    set helplang=cn
    set encoding=utf-8
endif

set ruler
set scrolloff=3 " 光标移动到buffer的顶部和底部时保持3行距离
set shortmess=atI
filetype plugin indent on

"打开文件类型检测, 加了这句才可以用智能补全
set completeopt=longest,menu 

filetype plugin on
filetype plugin indent on

"C,C++ 按F5编译运行
map <F5> :call CompileRunGcc()<CR>
func! CompileRunGcc() 
    exec "w"
    if &filetype == 'c'
        exec "!g++ % -o %< -Wall"
        exec "! ./%<"
    elseif &filetype == 'cpp'
        exec "!g++ % -o %< -Wall"
        exec "! ./%<"
    endif
endfunc

"C,C++的调试
map <F8> :call Rungdb()<CR>
func! Rungdb()
    exec "w"
    exec "!g++ % -g -o % -Wall<"
    exec "!gdb ./%<"
endfunc

"搜索逐字符高亮
set hlsearch 
set incsearch

"自动补全
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap { {<CR>}<ESC>O
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap " ""<ESC>i
:inoremap ' ''<ESC>i
function! ClosePair(char)
    if getline('.')[col('.') - 1] == a:char
        return "\<Right>"
    else
        return a:char
    endif
endfunction
filetype plugin indent on
Last modification:October 25th, 2018 at 03:10 pm
If you think my article is useful to you, please feel free to appreciate

One comment

  1. GldHkkowo

    orz

Leave a Comment