Skip to content

Instantly share code, notes, and snippets.

@Kazark
Last active January 13, 2023 03:40
Show Gist options
  • Save Kazark/c37b040af4b2282b581f to your computer and use it in GitHub Desktop.
Save Kazark/c37b040af4b2282b581f to your computer and use it in GitHub Desktop.
My VsVim configuration
" Gist ID: c37b040af4b2282b581f
set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4
set hlsearch
set incsearch
set autoindent
"set cindent "Unknown to VsVim
set backspace=indent,eol,start
let mapleader=","
" Specific to VsVim in VS >= 2013
cnoremap pin vscmd Window.KeepTabOpen<CR>
" ReSharper =================================================================
" Navigation ----------------------------------------------------------------
map <leader>gi :vscmd ReSharper.ReSharper_GotoImplementation<CR>
map <leader>fu :vscmd ReSharper.ReSharper_FindUsages<CR>
" Refactoring ---------------------------------------------------------------
map <leader>r :vscmd ReSharper.ReSharper_Rename<CR>
vmap <leader>em :vscmd ReSharper.ReSharper_ExtractMethod<CR>
vmap <leader>iv :vscmd ReSharper.ReSharper_IntroduceVariable<CR>
vmap <leader>if :vscmd ReSharper.ReSharper_IntroduceField<CR>
map <leader>in :vscmd ReSharper.ReSharper_InlineVariable<CR>
" Unit tests ----------------------------------------------------------------
" *U*nit test *S*pecific (or *S*ession, or *S*ome)
map <leader>us :vscmd ReSharper.ReSharper_UnitTest_RunCurrentSession<CR>
" *U*nit test *A*ll
map <leader>ua :vscmd ReSharper.ReSharper_UnitTest_RunSolution<CR>
" ReSharper =================================================================
" From my "Leading, not Control" plugin
" https://github.com/Kazark/vim-leading-not-control
nmap <Space>d <C-d>
nmap <Space>e <C-e>
nmap <Space>g <C-g>
nmap <Space>l <C-l>
nmap <Space>t <C-t>
nmap <Space>u <C-u>
nmap <Space>v <C-v>
nmap <Space>w <C-w>
nmap <Space>y <C-y>
nmap <Space>] <C-]>
nmap g<Space>g g<C-g>
" From my Kazarc plugin https://github.com/Kazark/vim-kazarc -----------------
" Why hold down the shift key? The default mapping of ; is not very useful
nmap ; :
vmap ; :
" Screw Vi-compatibility; let's make sense around here
" From http://vimrcfu.com/snippet/88
map Y y$
" Neovim is going to kill Ex mode. That means, as far as I'm concerned, Q is
" free. And :noh is a perennial nuisance...
nnoremap <silent> Q :nohlsearch<CR>
" From http://vimrcfu.com/snippet/14
" "It's stupid that indenting or unindenting a visual block deselects the
" block. Automatically 'gv' (go to previously selected visual block) after
" indenting or unindenting." --@dwieeb
vnoremap < <gv
vnoremap > >gv
" From http://vimrcfu.com/snippet/106
nnoremap <Tab> >>
nnoremap <S-Tab> <LT><LT>
vnoremap <Tab> >gv
vnoremap <S-Tab> <LT>gv
" Feels right
nnoremap <silent> <bar><lt> :left<CR>
xnoremap <silent> <bar><lt> :'<,'>left<CR>
" I select everything in a file far more than I increment an integer! Why not
" make CTRL-A do what it does in almost every other program?
nmap <C-a> ggVG
" CTRL-C doesn't do anything valuable in Normal or Visual mode. Why not map it
" to what it does in almost every other program?
vmap <C-c> "+y
nmap <C-c> "+yy
" Why not make Visual block mode use CTRL-B so we can free up CTRL-V for CUA?
nnoremap <C-b> <C-v>
nnoremap <C-v> "+p
vnoremap <C-v> "+p
nnoremap <C-x> "+dd
vnoremap <C-x> "+d
" Like ZZ and ZQ...
nmap <silent> ZA :qa<CR>
" Underscore-related motions
map <leader>w f_l
map <leader>b hT_
map <leader>e lt_
omap u t_
omap U f_
" Like Q, q only ever causes me trouble. I never use it deliberately
map q <nop>
" However I do want to maintain the q: functionality
nmap q: q:
" Quickfix mappings
nnoremap <silent> qff :cc<CR>
nnoremap <silent> qfj :cn<CR>
nnoremap <silent> qfk :cN<CR>
nnoremap <silent> qfl :cnf<CR>
nnoremap <silent> qfh :cNf<CR>
" Tab mappings analogous to window mappings where <leader>t is like <C-w>
map <silent> <leader>tc :tabclose<CR>
map <silent> <leader>tn :tabnew<CR>
" From my Kazarc plugin https://github.com/Kazark/vim-kazarc -----------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment