mirror of https://github.com/einverne/dotfiles.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
99 lines
2.2 KiB
99 lines
2.2 KiB
" vim map setting |
|
|
|
" Treat long lines as break lines (useful when moving around in them) |
|
map j gj |
|
map k gk |
|
nnoremap j gj |
|
nnoremap k gk |
|
|
|
" fast saving |
|
nmap <leader>w :w!<cr> |
|
|
|
" use tab as % |
|
nmap <tab> % |
|
vmap <tab> % |
|
|
|
" smart way to move between windows |
|
map <C-j> <C-W>j |
|
map <C-k> <C-W>k |
|
map <C-h> <C-W>h |
|
map <C-l> <C-W>l |
|
|
|
" Useful mappings for managin tabs |
|
map <leader>tn :tabnew<cr> |
|
map <leader>to :tabonly<cr> |
|
map <leader>tc :tabclose<cr> |
|
|
|
" Disable arrowkeys |
|
noremap <Up> <Nop> |
|
noremap <Down> <Nop> |
|
noremap <Left> <Nop> |
|
noremap <Right> <Nop> |
|
|
|
" visual mode copy and paste to system clipboard |
|
"vmap <C-c> "+y |
|
"vmap <C-x> "+c |
|
"vmap <C-v> "+p |
|
|
|
" 将VIM中将内容复制到系统粘贴板,或者从系统粘贴板粘贴到VIM |
|
nnoremap <C-y> "+y |
|
vnoremap <C-y> "+y |
|
vnoremap <C-p> "+gP |
|
nnoremap <C-p> "+gP |
|
|
|
" 快速移动当前行 |
|
nnoremap <A-j> :m .+1<CR>== |
|
nnoremap <A-k> :m .-2<CR>== |
|
inoremap <A-j> <Esc>:m .+1<CR>==gi |
|
inoremap <A-k> <Esc>:m .-2<CR>==gi |
|
vnoremap <A-j> :m '>+1<CR>gv=gv |
|
vnoremap <A-k> :m '<-2<CR>gv=gv |
|
|
|
" 空格关闭高亮,清空所有已经显示 |
|
nnoremap <Space> :set hlsearch! hlsearch?<CR> |
|
|
|
" Save a file as root (,W) |
|
noremap <leader>W :w !sudo tee % > /dev/null<CR> |
|
|
|
" sudo write |
|
" https://catonmat.net/sudo-vim |
|
cnoremap sudow w !sudo tee % >/dev/null |
|
|
|
" Strip trailing whitespace (,ss) |
|
function! StripWhitespace() |
|
let save_cursor = getpos(".") |
|
let old_query = getreg('/') |
|
:%s/\s\+$//e |
|
call setpos('.', save_cursor) |
|
call setreg('/', old_query) |
|
endfunction |
|
noremap <leader>ss :call StripWhitespace()<CR> |
|
|
|
set hidden " 避免必须保存修改才可以跳转 buffer |
|
" buffer |
|
"nmap <leader>n :bnext<CR> |
|
"nmap <leader>p :bprev<CR> |
|
|
|
function! Xml() |
|
set filetype=xml |
|
:%s/></>\r</g "把><替换成>回车< |
|
:normal gg=G<cr> |
|
endfunction |
|
map <leader>xml :call Xml() |
|
|
|
" plugin map setting |
|
|
|
" Normal mode F2 to call NERDTree |
|
nmap <F2> :NERDTreeToggle<cr> |
|
|
|
nnoremap <leader><leader>i :PlugInstall<CR> |
|
nnoremap <leader><leader>u :PlugUpdate<CR> |
|
|
|
" fzf |
|
nnoremap <leader><leader> :GFiles<cr> |
|
nnoremap <leader>f :Files<cr> |
|
nnoremap <leader>C :Colors<CR> |
|
nnoremap <leader><CR> :Buffers<CR> |
|
nnoremap <leader>fl :Lines<CR> |
|
nnoremap <leader>ag :Ag! <C-R><C-W><CR> |
|
nnoremap <leader>m :History<CR>
|
|
|