Vim for Visual Studio 2015 and Above: Setup, Keybindings, and Tips
- Published on
- • 2 mins read•--- views
Today I'm gonna show you one awesome plugin that will add VIM mode to your Visual Studio 2015 and above. The plugin called VsVim, the link for visual studio marketplace - [link]. You can simply install it from Tools -> Extensions and updates

In the modal window, choose tab Online, type VsVim in the search box and download the most relevant option

Restart your Visual Studio after that. After the restart, you will see a window that says about some keymappings conflicts with plugin and VS. Choose all mappings for VsVim or something like that. Main idea - override all VS rules with VsVim rules. It's ok, don't worry. Awesome, now you can use vim in your VS! Try combinations like I (for insert move), V (Visual Mode), and move cursor overall working area with VIM buttons such as H, J, K, L, and so on.
Some recommendations:
Also, I Can recommend you to do some settings for VIM mode, that are very common: JJ for Esc (allows you to quit edit mode faster from JJ combination, same as by <ESC>
)
<pre class="lang:default" decode:true="">:imap jj <ESC>
Unmap Crtl + S (allows you to save faster with Ctrl + S that will handle by VSStudio, not vim. In vim you should always type :w for saving docs)
<pre class="lang:default" decode:true="">nnoremap <c-s> :w<CR> # normal mode: save
inoremap <c-s> <Esc>:w<CR>l # insert mode: escape to normal and save
vnoremap <c-s> <Esc>:w<CR># visual mode: escape to normal and save
You can save all these settings in .vsvimrc file and they will be applied each visual studio load. How to do it - read here: https://github.com/cboudereau/vsvimrc
.vimrc file location:

Example of my current .vimrc-file:
" version control
nnoremap Ud :vsc Team.Git.CompareWithUnmodified<cr>
" from https://github.com/justinmk/config/blob/master/.vsvimrc
nnoremap yxx ggVG:vsc
EditorContextMenus.CodeWindow.ExecuteInInteractive<cr>
" fsharp refactoring
" not yet implemented
nnoremap Un i failwith "not yet implemented"
" extract (p/P)arameter
nnoremap Up
yawOlet<Space><Esc>Pa<Space>=<Space>failwith<Space>"not<Space>yet<Space>implemented"<Esc>j$i
nnoremap UP
ciw<Esc>pa=<Esc>p<Esc>yawOlet<Space><Space><Esc>Pa<Space>=<Space>failwith<Space>"not<Space>yet<Space>implemented"<Esc>j$i
" convert to Union (C)ase
nnoremap Uc
<Esc>diwatype<Space>[<Struct>]<Space><Esc>pa<Space>=<Space><Esc>pa<Space>of<Space>string
" extract (R)ecord member type to (I)dentifier
nnoremap Uri
/:<CR>d$byiw$a=<Space><Esc>pbvuyiw?{<CR>Olet<Space><Esc>pa<Space>=<Space>failwith
"not yet implemented"<Esc>''<Esc>
" fsharp interactiv(E/e)
nnoremap Ue Vggo:vsc
EditorContextMenus.CodeWindow.ExecuteInInteractive<cr>
nnoremap UE VGGo:vsc
EditorContextMenus.CodeWindow.ExecuteInInteractive<cr>
imap jj <ESC>
nnoremap <c-s> :w<CR>
inoremap <c-s> <Esc>:w<CR>l
vnoremap <c-s> <Esc>:w<CR>
set clipboard=unnamed
Also, I recommend you print this useful cheatsheet for VIM.
