From b03e4ae8b95e781b74f8e2d969249cbf5119ef1b Mon Sep 17 00:00:00 2001 From: wklken Date: Tue, 7 Jul 2015 15:05:49 +0800 Subject: [PATCH] add some more config --- vimrc | 148 +++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 104 insertions(+), 44 deletions(-) diff --git a/vimrc b/vimrc index d7ee52d..3c26480 100644 --- a/vimrc +++ b/vimrc @@ -1,13 +1,12 @@ "========================================== " ProjectLink: https://github.com/wklken/vim-for-server " Author: wklken -" Version: 0.1 +" Version: 0.2 " Email: wklken@yeah.net " BlogPost: http://www.wklken.me " Donation: http://www.wklken.me/pages/donation.html " ReadMe: README.md -" Last_modify: 2014-11-02 -" Sections: +" Last_modify: 2015-07-07 " Desc: simple vim config for server, without any plugins. "========================================== @@ -36,8 +35,9 @@ set shortmess=atI set magic " For regular expressions turn magic on set title " change the terminal's title set nobackup " do not keep a backup file + set novisualbell " turn off visual bell -set noerrorbells " don't beep +set noerrorbells " don't beep set visualbell t_vb= " turn off error beep/flash set t_vb= set tm=500 @@ -51,21 +51,6 @@ set cursorline " movement set scrolloff=7 " keep 3 lines when scrolling -nnoremap k gk -nnoremap gk k -nnoremap j gj -nnoremap gj j - -map j -map k -map h -map l - -cnoremap -cnoremap -cnoremap -cnoremap - " show set ruler " show the current row and column @@ -83,7 +68,6 @@ set incsearch " do incremental searching, search as you type set ignorecase " ignore case when searching set smartcase " no ignorecase if Uppercase char present -noremap / :nohls " tab set expandtab " expand tabs to spaces @@ -96,14 +80,22 @@ set shiftwidth=4 set tabstop=4 set softtabstop=4 " insert mode tab and backspace use 4 spaces -vnoremap < >gv - " NOT SUPPORT " fold -" set foldenable -" set foldmethod=indent -" set foldlevel=99 +set foldenable +set foldmethod=indent +set foldlevel=99 +let g:FoldMethod = 0 +map zz :call ToggleFold() +fun! ToggleFold() + if g:FoldMethod == 0 + exe "normal! zM" + let g:FoldMethod = 1 + else + exe "normal! zR" + let g:FoldMethod = 0 + endif +endfun " encoding set encoding=utf-8 @@ -122,6 +114,9 @@ set wildmenu " show a navigable menu for tab completio set wildmode=longest,list,full set wildignore=*.o,*~,*.pyc,*.class +" others +set backspace=indent,eol,start " make that backspace key work the way it should +set whichwrap+=<,>,h,l " if this not work ,make sure .viminfo is writable for you if has("autocmd") @@ -132,10 +127,14 @@ endif " Enable basic mouse behavior such as resizing buffers. " set mouse=a + +" ============================ theme and status line ============================ + " theme set background=dark colorscheme desert +" set mark column color hi! link SignColumn LineNr hi! link ShowMarksHLl DiffAdd hi! link ShowMarksHLu DiffChange @@ -144,9 +143,12 @@ hi! link ShowMarksHLu DiffChange set statusline=%<%f\ %h%m%r%=%k[%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",BOM\":\"\")}]\ %-14.(%l,%c%V%)\ %P set laststatus=2 " Always show the status line - use 2 lines for the status bar -" specific language + +" ============================ specific file type =========================== + autocmd FileType python set tabstop=4 shiftwidth=4 expandtab ai autocmd FileType ruby set tabstop=2 shiftwidth=2 softtabstop=2 expandtab ai +autocmd BufRead,BufNew *.md,*.mkd,*.markdown set filetype=markdown.mkd autocmd BufNewFile *.sh,*.py exec ":call AutoSetFileHead()" function! AutoSetFileHead() @@ -166,27 +168,85 @@ function! AutoSetFileHead() normal o endfunc -" others -set backspace=indent,eol,start " make that backspace key work the way it should -set whichwrap+=<,>,h,l -cmap w!! w !sudo tee >/dev/null % - -" kj 替换 Esc -inoremap kj - -nnoremap :set nu! nu? -nnoremap :set list! list? -nnoremap :set wrap! wrap? -nnoremap :exec exists('syntax_on') ? 'syn off' : 'syn on' - -set pastetoggle= -au InsertLeave * set nopaste - +autocmd FileType c,cpp,java,go,php,javascript,puppet,python,rust,twig,xml,yml,perl autocmd BufWritePre :call StripTrailingWhitespaces() fun! StripTrailingWhitespaces() let l = line(".") let c = col(".") %s/\s\+$//e call cursor(l, c) endfun -autocmd FileType c,cpp,java,go,php,javascript,puppet,python,rust,twig,xml,yml,perl autocmd BufWritePre :call StripTrailingWhitespaces() +" ============================ key map ============================ + +nnoremap k gk +nnoremap gk k +nnoremap j gj +nnoremap gj j + +map j +map k +map h +map l + +nnoremap :set nu! nu? +nnoremap :set list! list? +nnoremap :set wrap! wrap? +set pastetoggle= " when in insert mode, press to go to + " paste mode, where you can paste mass data + " that won't be autoindented +au InsertLeave * set nopaste +nnoremap :exec exists('syntax_on') ? 'syn off' : 'syn on' + +" kj 替换 Esc +inoremap kj + +" Quickly close the current window +nnoremap q :q +" Quickly save the current file +nnoremap w :w + +" select all +map sa ggVG" + +" remap U to for easier redo +nnoremap U + +" Swap implementations of ` and ' jump to markers +" By default, ' jumps to the marked line, ` jumps to the marked line and +" column, so swap them +nnoremap ' ` +nnoremap ` ' + +" switch # * +" nnoremap # * +" nnoremap * # + +"Keep search pattern at the center of the screen." +nnoremap n nzz +nnoremap N Nzz +nnoremap * *zz +nnoremap # #zz +nnoremap g* g*zz + +" remove highlight +noremap / :nohls + +"Reselect visual block after indent/outdent.调整缩进后自动选中,方便再次操作 +vnoremap < >gv + +" y$ -> Y Make Y behave like other capitals +map Y y$ + +"Map ; to : and save a million keystrokes +" ex mode commands made easy 用于快速进入命令行 +nnoremap ; : + +" save +cmap w!! w !sudo tee >/dev/null % + +" command mode, ctrl-a to head, ctrl-e to tail +cnoremap +cnoremap +cnoremap +cnoremap