my vimrc


"basic operation
set autoindent
set ts=4

cmap Q q
cmap W w
cmap WQ wq
cmap Wq wq
cmap tn tabnew

map <C-h> ^
map <C-l> $
map <C-k> {
map <C-j> }


"search, and replace the string or text
vnoremap ,s y/<C-R>"<CR>
vnoremap ,r y:%s/<C-R>"//g<left><left>

"save the file with root permission
cmap w!! w !sudo tee >/dev/null %

"NERD_tree plugin
"git clone [email protected]:scrooloose/nerdtree
noremap <F4> :NERDTreeToggle<CR>
                            
"save and reload the folders, the path of folder is ~/.vim/view
au BufWinLeave * mkview
au BufWinEnter * silent loadview

"comment/uncomment
autocmd FileType c,cpp,java,scala,php let b:comment_leader = '// '
autocmd FileType sh,ruby,python   let b:comment_leader = '# '
autocmd FileType conf,fstab       let b:comment_leader = '# '
autocmd FileType tex              let b:comment_leader = '% '
autocmd FileType mail             let b:comment_leader = '> '
autocmd FileType vim              let b:comment_leader = '" '

noremap <silent> ,cc :<C-B>silent <C-E>s/^/<C-R>=escape(b:comment_leader,'\/')<CR>/<CR>:nohlsearch<CR>
noremap <silent> ,cu :<C-B>silent <C-E>s/^\V<C-R>=escape(b:comment_leader,'\/')<CR>//e<CR>:nohlsearch<CR>


你可能感兴趣的:(vi,vim)