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>)
1 |
: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)
1 2 3 |
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
Example of my current .vimrc-file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
" 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.