vimrc: Add incremental searching, easy-motions and some bindings

This commit is contained in:
kuben
2019-09-17 11:45:18 +02:00
parent 65b6d539aa
commit 3e4c8b0dfe

32
.vimrc
View File

@@ -21,11 +21,13 @@ if filereadable(expand(vundle_dir) . "/README.md")
" Plugin 'shougo/neocomplete' " Plugin 'shougo/neocomplete'
Plugin 'godlygeek/tabular' Plugin 'godlygeek/tabular'
Plugin 'airblade/vim-gitgutter' Plugin 'airblade/vim-gitgutter'
Plugin 'jeetsukumaran/vim-pythonsense'
Plugin 'easymotion/vim-easymotion'
call vundle#end() " required call vundle#end() " required
else else
let vundle_repo="https://github.com/VundleVim/Vundle.vim.git" let vundle_repo="https://github.com/VundleVim/Vundle.vim.git"
echo "Vundle not installed, type :CloneVundle to clone the vundle repo" echo "Vundle not installed, type :CloneVundle to clone the vundle repo and install it"
command CloneVundle execute "!git clone " . vundle_repo . " " . vundle_dir command CloneVundle execute "!git clone " . vundle_repo . " " . vundle_dir
endif endif
@@ -45,6 +47,7 @@ set expandtab " On pressing tab, insert 4 spaces
set mouse=a set mouse=a
set hlsearch set hlsearch
set scrolloff=5 " Don't let cursor be within 5 lines from top or bottom
" Warn for trailing whitespace. Search with wrap (w) do not move cursor (n) " Warn for trailing whitespace. Search with wrap (w) do not move cursor (n)
function! WhitespaceWarn() function! WhitespaceWarn()
@@ -73,6 +76,11 @@ augroup numbertoggle
autocmd BufLeave,FocusLost,InsertEnter * set nornu autocmd BufLeave,FocusLost,InsertEnter * set nornu
augroup END augroup END
" Do incremental searching when it's possible to timeout.
if has('reltime')
set incsearch
endif
" Copy to the end of line " Copy to the end of line
noremap Y y$ noremap Y y$
@@ -118,8 +126,6 @@ command! Csc cscope find c <cword>
" Regen cscope " Regen cscope
" sh ~/bin/gen_cscope.sh . .git/cscope.out " sh ~/bin/gen_cscope.sh . .git/cscope.out
" "
" Key binds
"
" Simulate maximize/minimize window " Simulate maximize/minimize window
nnoremap <C-w>m :call ToggleMiniMaxiWin()<CR> nnoremap <C-w>m :call ToggleMiniMaxiWin()<CR>
@@ -137,8 +143,13 @@ function! ToggleMiniMaxiWin()
endif endif
endfunction endfunction
" Key binds
"
" Replace the word under cursor " Replace the word under cursor
nnoremap <leader>* :%s/\<<c-r><c-w>\>//g<left><left> nnoremap <leader>* :%s/\<<c-r><c-w>\>//g<left><left>
" Replace visual selection
vnoremap <leader>* y:%sno/<c-r>"//g<left><left>
nmap <F2> :NERDTreeToggle<CR> nmap <F2> :NERDTreeToggle<CR>
nmap <F3> :NERDTreeFind<CR> nmap <F3> :NERDTreeFind<CR>
@@ -156,3 +167,18 @@ nmap <Leader>vv :vsp $MYVIMRC <CR>
nmap <Leader>vt :tabnew $MYVIMRC <CR> nmap <Leader>vt :tabnew $MYVIMRC <CR>
nmap <Leader>vo :e $MYVIMRC <CR> nmap <Leader>vo :e $MYVIMRC <CR>
nmap <Leader>v :e $MYVIMRC <CR> nmap <Leader>v :e $MYVIMRC <CR>
" Match git conflict markers
nmap <Leader>/g /[<=>]\{7,}.*$<CR>
" Toggle wrapping of long lines
nmap <Leader>l :set wrap!<CR>
" Scroll window while keeping cursor on same line with shift
nmap <S-j> <c-e>
nmap <S-k> <c-y>
vmap <S-j> <c-e>
vmap <S-k> <c-y>
" Misc.
vmap <Leader>T :'<,'> Tabularize /