├── .gitignore ├── Examples ├── .gitignore ├── Kata.Tennis │ ├── Kata.Tennis.csproj │ └── TennisScoring.cs ├── VsVimGuide.Tests │ ├── UnitTest1.cs │ └── VsVimGuide.Tests.csproj ├── VsVimGuide.sln └── VsVimGuide │ ├── App.cs │ ├── Program.cs │ └── VsVimGuide.csproj ├── README.md └── vsvim.ahk /.gitignore: -------------------------------------------------------------------------------- 1 | *.ahk - Shortcut.lnk 2 | -------------------------------------------------------------------------------- /Examples/.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.*~ 3 | project.lock.json 4 | .DS_Store 5 | *.pyc 6 | 7 | # Visual Studio Code 8 | .vscode 9 | 10 | # User-specific files 11 | *.suo 12 | *.user 13 | *.userosscache 14 | *.sln.docstates 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | build/ 24 | bld/ 25 | [Bb]in/ 26 | [Oo]bj/ 27 | msbuild.log 28 | msbuild.err 29 | msbuild.wrn 30 | 31 | # Visual Studio 2015 32 | .vs/ 33 | -------------------------------------------------------------------------------- /Examples/Kata.Tennis/Kata.Tennis.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | all 14 | runtime; build; native; contentfiles; analyzers 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Examples/Kata.Tennis/TennisScoring.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Runtime.InteropServices.WindowsRuntime; 6 | using Xunit; 7 | 8 | namespace Kata.Tennis 9 | { 10 | public class TennisScoring 11 | { 12 | private readonly TennisGame _tennisGame; 13 | 14 | public TennisScoring() 15 | { 16 | _tennisGame = new TennisGame(); 17 | } 18 | 19 | [Theory] 20 | [InlineData(0, 0, "Love All")] 21 | [InlineData(1, 0, "Fifteen Love")] 22 | [InlineData(1, 1, "Fifteen All")] 23 | [InlineData(2, 1, "Thirty Fifteen")] 24 | [InlineData(2, 2, "Thirty All")] 25 | [InlineData(3, 2, "Forty Thirty")] 26 | [InlineData(3, 3, "Deuce")] 27 | [InlineData(4, 3, "Advantage Player One")] 28 | [InlineData(5, 3, "Player One Wins")] 29 | [InlineData(3, 5, "Player Two Wins")] 30 | [InlineData(4, 4, "Deuce")] 31 | [InlineData(4, 5, "Advantage Player Two")] 32 | [InlineData(4, 6, "Player Two Wins")] 33 | public void Score(int first, int second, string score) 34 | { 35 | Enumerable.Range(0, first).ToList().ForEach(n => _tennisGame.Scores(TennisPlayer.One)); 36 | Enumerable.Range(0, second).ToList().ForEach(n => _tennisGame.Scores(TennisPlayer.Two)); 37 | Assert.Equal(score, _tennisGame.Score); 38 | } 39 | } 40 | 41 | public class TennisGame 42 | { 43 | private (TennisScore one, TennisScore two) _scores = (TennisScore.Love, TennisScore.Love); 44 | 45 | public void Scores(TennisPlayer player) => _scores = 46 | player == TennisPlayer.One ? IncrementScore(_scores) : Flip(IncrementScore(Flip(_scores))); 47 | 48 | private (TennisScore, TennisScore) Flip((TennisScore one, TennisScore two) scores) => (scores.two, scores.one); 49 | 50 | private (TennisScore, TennisScore) IncrementScore( (TennisScore currentPlayer, TennisScore otherPlayer ) scores) 51 | { 52 | if (scores.otherPlayer == TennisScore.Advantage && scores.currentPlayer == TennisScore.Forty) scores.otherPlayer--; 53 | else scores.currentPlayer++; 54 | return scores; 55 | } 56 | 57 | public string Score 58 | { 59 | get 60 | { 61 | var scores = _scores; 62 | if (scores.two == TennisScore.Wins) return $"Player Two Wins"; 63 | if (scores.one == TennisScore.Wins) return $"Player One Wins"; 64 | if (scores.two == TennisScore.Advantage) return $"Advantage Player Two"; 65 | if (scores.one == TennisScore.Advantage) return $"Advantage Player One"; 66 | if (scores.one == scores.two && scores.one == TennisScore.Forty) return "Deuce"; 67 | if (scores.one == scores.two) return $"{scores.one} All"; 68 | return $"{scores.one} {scores.two}"; 69 | } 70 | } 71 | } 72 | 73 | public enum TennisPlayer 74 | { 75 | One, 76 | Two 77 | } 78 | 79 | public enum TennisScore 80 | { 81 | Love, 82 | Fifteen, 83 | Thirty, 84 | Forty, 85 | Advantage, 86 | Wins 87 | } 88 | } -------------------------------------------------------------------------------- /Examples/VsVimGuide.Tests/UnitTest1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit; 3 | 4 | namespace VsVimGuide.Tests 5 | { 6 | public class UnitTest1 7 | { 8 | [Fact] 9 | public void Test1() 10 | { 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Examples/VsVimGuide.Tests/VsVimGuide.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | all 14 | runtime; build; native; contentfiles; analyzers 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Examples/VsVimGuide.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28010.2046 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VsVimGuide", "VsVimGuide\VsVimGuide.csproj", "{190536B6-10F9-4E3F-8CEE-58E211BCE8FA}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VsVimGuide.Tests", "VsVimGuide.Tests\VsVimGuide.Tests.csproj", "{7EE49F2F-C9ED-4855-8E2D-8103BBBCA04C}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kata.Tennis", "Kata.Tennis\Kata.Tennis.csproj", "{729A2FC6-3856-413B-BECC-75E56B1A2D86}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {190536B6-10F9-4E3F-8CEE-58E211BCE8FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {190536B6-10F9-4E3F-8CEE-58E211BCE8FA}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {190536B6-10F9-4E3F-8CEE-58E211BCE8FA}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {190536B6-10F9-4E3F-8CEE-58E211BCE8FA}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {7EE49F2F-C9ED-4855-8E2D-8103BBBCA04C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {7EE49F2F-C9ED-4855-8E2D-8103BBBCA04C}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {7EE49F2F-C9ED-4855-8E2D-8103BBBCA04C}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {7EE49F2F-C9ED-4855-8E2D-8103BBBCA04C}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {729A2FC6-3856-413B-BECC-75E56B1A2D86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {729A2FC6-3856-413B-BECC-75E56B1A2D86}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {729A2FC6-3856-413B-BECC-75E56B1A2D86}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {729A2FC6-3856-413B-BECC-75E56B1A2D86}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {F969A00D-858F-47BC-B5FF-4A23C1DB79AD} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /Examples/VsVimGuide/App.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Extensions.Logging; 3 | 4 | namespace VsVimGuide 5 | { 6 | internal class App : IDisposable 7 | { 8 | private readonly ILogger _logger; 9 | 10 | public App(ILogger logger) 11 | { 12 | _logger = logger; 13 | } 14 | 15 | public void Dispose() { } 16 | 17 | public void Run() 18 | { 19 | _logger.LogInformation("Running!"); 20 | 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Examples/VsVimGuide/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using Microsoft.Extensions.Logging; 3 | 4 | namespace VsVimGuide 5 | { 6 | class Program 7 | { 8 | static void Main(string[] args) 9 | { 10 | var services = new ServiceCollection() 11 | .AddLogging(cfg => cfg.AddConsole()) 12 | .AddScoped(); 13 | using (var provider = services.BuildServiceProvider()) 14 | using (var app = provider.GetService()) 15 | { 16 | app.Run(); 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Examples/VsVimGuide/VsVimGuide.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VsVim + Resharper Guide with C# editing scenarios 2 | 3 | UPDATE: I now use Rider instead of Visual Studio, it comes with the most excellent IdeaVim plugin. As such I won't be updating this guide but I will likely start a guide to using IdeaVim in Rider. 4 | 5 | Stack: Visual Studio 2017 - Resharper 2018.2 - VsVim 2.6 - AceJump - AutoHotKey - RelativeLineNumbers 6 | 7 | This is an opinionated guide on how to use Resharper and VsVim together for C# programming ( While still applicable for F# and VB.NET, the examples and focus on C#) 8 | 9 | Vims power comes from chaining combinations together, and while much of vim is well documented it is often hard to learn effective combos, and with Resharper we have a lot more combos at our disposal. The purpose of this guide is to document really good VsVim / Resharper editing techniques by leveraging various combos. 10 | 11 | If there are any editing scenarios in relation to C# coding not covered raise an issue, or, if you have a scenario you think would be good for the guide, raise a PR on the repository 12 | https://github.com/keithn/vsvimguide.git 13 | 14 | # Setup 15 | 16 | This is largely down to personal preference, but by default, some things are slightly tricky to deal with and adaptions / compromises need to be made. The following is an opinionated setup that is meant as a starting point for customization. 17 | 18 | ## Visual Studio 19 | 20 | Visual Studio provides lots of mouseable targets on the screen. For keyboard oriented programming these targets are really not needed and every time you have to reach for your mouse it feels like wasted time. Unfortunately a lot of the Visual Studio Modals are not very keyboard friendly, you can drive them through the keyboard, but it is often semi painful. The following changes are recommend ( though not necessary ) 21 | 22 | - Enter Full Screen ( View -> Fullscreen or ```Shift-Alt-Enter``` ) 23 | - Turn off all toolbars. You will access all the functionality you need through the keyboard 24 | - Unpin all the side / bottom tool windows. 25 | - Turn off sidebar tabs (Window -> Show Sidebar Tabs, or ```ALT-W b```) 26 | - Turn off scrollbars (Tools -> Options -> Text Editor -> All Languages -> Scrollbars) 27 | - Turn on line numbers (Tools -> Options -> Text Editor -> General -> Line Numbers) 28 | 29 | Turning off scrollbars tends to be the most surprising setting for people used to using a mouse. You'll find that you don't actually use the scrollbars too often and the times you do want to scroll through your code with your mouse you find the mousewheel tends to be good enough. 30 | 31 | ## Resharper / VsVim Handling of Ctrl 32 | 33 | In the VsVim Settings you can set whether VsVim or VisualStudio should handle the various Ctrl key combinations, there is fine grained control over the various Ctrl combinations, but in general, prefer using VsVim if VsVim has functionality that uses Ctrl. Key Combinations that involve Shift and Alt are fine and don't clash with VsVim so can be left as desired though you can also optionally map combos to Vim friendly combos also. You can leave the following ```Ctrl``` keys left bound to visual studio 34 | 35 | ```Ctrl-t``` - Not supported by VsVim, so nicer left bound to resharpers search functions 36 | 37 | ## Unit Testing 38 | 39 | Resharpers unit test runner is quite powerful but it can be difficult to setup through the keyboard so it is generally better to use the mouse to set it up. However once you set the settings correctly, the general process of unit testing is fully keyboard driven. The following are some general tips on how to make the best use of it 40 | 41 | - Dock it as window rather than a toolbar window, size it so it's easy to read the failure messages 42 | - Set Autoscroll on 43 | - Set Autostart on so it will Run all tests on Build 44 | 45 | ### Key Bindings 46 | 47 | Running unit tests is handled from the Vim bindings, but there are number of options you will want to set in the Unit Test Session that ReSharper provides. The following are recommend bindings for the Unit Session Window 48 | 49 | ```Alt-1``` - ReSharper.UnitTestSessionAutoScrollOutput 50 | 51 | ```Alt-2``` - ReSharper.UnitTestSessionTrackRunningTest 52 | 53 | ```Alt-3``` - ReSharper.ContinuousTestingRunNewAndOutdatedMode 54 | 55 | ```Alt-4``` - ReSharper.ContinuousTestingRunNewAndOutdatedMode 56 | 57 | ```Alt-5``` - ReSharper.ContinuousTestingCoverNewAndOutdatedMode 58 | 59 | Toggling Any of the ```Alt 3 4 5``` will turn off Continuous Test Mode 60 | 61 | ## .vsvimrc 62 | 63 | This is where you can map keys like the traditional vim editor (it lives in your windows user home directory). VsVim also allows you to bind things to visual studio commands, and by extension, resharper. The following are a number of useful bindings 64 | 65 | ``` 66 | set ignorecase 67 | set clipboard=unnamed 68 | 69 | map gd :vsc ReSharper.ReSharper_GotoDeclaration 70 | map r :vsc ReSharper.ReSharper_Rename 71 | map f :vsc ReSharper.ReSharper_GotoFileMember 72 | map e :vsc ReSharper.ReSharper_GotoNextErrorInSolution 73 | map E :vsc ReSharper.ReSharper_GotoPrevErrorInSolution 74 | map s :vsc ReSharper.ReSharper_SurroundWith 75 | map l :vsc ReSharper.ReSharper_LiveTemplatesInsert 76 | map u :vsc ReSharper.ReSharper_GotoUsage 77 | map d :vsc ReSharper.ReSharper_DuplicateText 78 | map , :vsc ReSharper.ReSharper_GotoText 79 | map v :vsc ReSharper.Resharper_IntroVariable 80 | map m :vsc ReSharper.ReSharper_ExtractMethod 81 | map o :vsc ReSharper.ReSharper_Move 82 | map t :vsc ReSharper.ReSharper_GotoType 83 | map tr :vsc ReSharper.ReSharper_UnitTestRunFromContext 84 | map td :vsc ReSharper.ReSharper_UnitTestDebugContext 85 | map ta :vsc ReSharper.ReSharper_UnitTestRunSolution 86 | map tl :vsc ReSharper.ReSharper_UnitTestSessionRepeatPreviousRun 87 | map tt :vsc ReSharper.ReSharper_ShowUnitTestSessions 88 | map / :vsc ReSharper.ReSharper_LineComment 89 | map qk :vsc Tools.CustomizeKeyboard 90 | map b :vsc Build.BuildSolution 91 | map :vsc Tools.InvokeAceJumpCommand 92 | map ; A; 93 | map ] :vsc ReSharper.ReSharper_GotoNextMethod 94 | map [ :vsc ReSharper.ReSharper_GotoPrevMethod 95 | map zl :so ~/.vsvimrc 96 | ``` 97 | 98 | To access non Vim things `````` is super useful, normally in Vim it would advance you one letter. In practice this is of limited use 99 | 100 | Most of these are bindings to resharper commands that VsVim hides, these are the commands that are normally bound to ```-``` to ```-```. Customize this to suit 101 | 102 | It also maps AceJump to ``````. AceJump allows you to quickly jump to different points in the code. See [AceJump in Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=jsturtevant.AceJump) for a demo of how it works. It is a limited implementation of a popular plugin in Vim called 'EasyMotion'. There is also a plugin for Visual Studio called easymotion which is written by the same author as VsVim, but ironically isn't compatible with VsVim. 103 | 104 | The ```[ ]``` keys are bound to next and previous method, the default Vim behavior is not generally that useful when coding C# / F# 105 | 106 | ```zl``` is just a quick way to reload your vim settings. WARNING - it doesn't reset your keybindings, so if you remove a mapping, and reload, it won't get rid of the mapping. But it is useful for loading new bindings / settings 107 | 108 | ## Auto Hot Key 109 | 110 | There are a number of bindings which Visual Studio and vsvim can't change when it comes to resharper and pop up dialogs. In this repository there is a auto hot key script (vsvim.ahk) which binds the following keys 111 | 112 | ```Caps Lock``` - ```Esc``` This is one of the most useful bindings as the ```Esc``` key is needed a lot and for many people they hardly ever use ```Caps Lock``` 113 | ```ALT-K``` - Up Arrow, this is for use in popup dialogs like any of R# goto dialogs 114 | ```ALT-J``` - Down Arrow 115 | 116 | Set this script to run on startup. 117 | 118 | The ```Alt-K``` and ```Alt-J``` Combos are useful in many cases where normally you'd have to use the arrow keys in windows or dropdown lists. Reaching for the arrow keys is generally always an annoying action for a Vimmer. If you haven't used VsVim and Resharper together yet then it won't be obvious that this happens a LOT with Resharper as you do various refactorings little dropdowns come up with various options, and it really slows you down if you have to reach for the arrow keys 119 | 120 | # VsVim Fundamentals 121 | 122 | The main reason for this guide is essentially how to use Vim effectively with visual studio and resharper. The key motivation to VsVim is to be able to leverage Vims powerful editing capabilities within Visual Studio, so we need to spend a lot of effort to get really effective with standard vim commands ( and specifically VsVim ). But often we step outside of Vim and make use of resharper / auto complete / refactorings / code generation / templates / Visual Studio hot keys to better leverage all the toys at our disposal 123 | 124 | ## How to switch to VsVim as a complete Noob 125 | 126 | This isn't trying to be a beginners guide but just some general advice for beginners about how to make the switch without too much friction. Vim takes a while to get good at and much of the advice advocates enduring the pain until you get good enough, but you don't have to. You can go through a progression. 127 | 128 | - It's ok to stay in insert mode, use arrow keys, and your mouse, everything will be semi normal 129 | - Start coming out of insert mode to practice Vim things, ```hjkl``` to move around, w to move between words, dd to delete lines, c commands to change text like ciw ci" cw, and the corresponding delete commands diw dw 130 | - Keep learning commands like the ones in this guide till you are using them by default 131 | - Start challenging yourself to stay out of insert mode 132 | - At this point you should start feeling Vim is a more productive way to edit and you'll naturally keep expanding your skills, keep looking at tips. It is not unusual for tips to open your eyes to completely different ways of how you can do things. 133 | 134 | ## Changing Text 135 | 136 | 137 | ```cw``` - changes the word from the cursor to the end of the word 138 | 139 | ```ciw``` - changes the entire worth that the cursor is on 140 | 141 | ```cf``` - changes text until you find the character ``````, includes the find char 142 | 143 | ```ct``` - changes text until you find the character ``````, but don't include the char 144 | 145 | ```cf``` - same as previous cf but find the nth occurrence of the char 146 | 147 | ```ct``` - same as previous ct but find the nth occurrence of the char 148 | 149 | ```ci(``` - change text inside current brackets ( ) 150 | 151 | ```ci{``` - change text inside current curly braces { } 152 | 153 | ```ci'``` - change text inside current ' quotes 154 | 155 | ```ci"``` - change text inside current " quotes 156 | 157 | ```cit``` - change text inside current html/xml tag 158 | 159 | ```r``` - replaces the character under the cursor 160 | 161 | ```r``` - replaces the next `````` characters from the cursor with `````` 162 | 163 | ```R``` - overwrite mode / Replace characters 164 | 165 | ```s``` - substitute, remove the character under cursor and enter insert mode 166 | 167 | ```s``` - remove the next `````` characters and enter insert mode 168 | 169 | ```o``` - open ( leave in insert mode) a new line under current line with correct indenting 170 | 171 | ```O``` - same as o, but open above 172 | 173 | ```x``` - delete character 174 | 175 | ```dd``` - delete line 176 | 177 | ```u``` - undo 178 | 179 | ```A``` - append to end of current line ( leaves in insert mode ) 180 | 181 | ```a``` - append after current cursor (leaves in insert mode ) 182 | 183 | ## Navigation 184 | 185 | ```h``` - cursor left 186 | 187 | ```j``` - cursor down 188 | 189 | ```k``` - cursor up 190 | 191 | ```l``` - cursor down 192 | 193 | ```H``` - put cursor at top of screen 194 | 195 | ```M``` - put cursor in middle of screen 196 | 197 | ```L``` - put cursor at bottom of screen 198 | 199 | ```w``` - beginning of next word 200 | 201 | ```e``` - end of next word 202 | 203 | ```b``` - beginning of previous word, if in the middle of a word, it goes back to the beginning of that word 204 | 205 | ```gd``` - goto definition ( use on top of methods / classes etc ) 206 | 207 | ```zz``` - center current line in center of screen 208 | 209 | ```*``` - search for word under cursor 210 | 211 | ```m``` - mark current location and store it in `````` if the letter is a Capital letter, then it works across files 212 | 213 | ``` ```` - goto mark set in `````` if the letter is a capital letter it will jump to the file with the mark 214 | 215 | ## Searching 216 | 217 | Use it to navigate to places faster 218 | 219 | ```/``` search forward, by itself repeats the last search but forwards 220 | 221 | ```?``` search back, by itself repeats the last search but backwards 222 | 223 | ```n``` find next, will go to the next forward or the next back ( depends on whether you used ```/``` or ```?```) 224 | 225 | ```N``` find previous, will go to the previous forward or the previous back 226 | 227 | 228 | From the .vsvimrc bindings 229 | 230 | ```[``` - Previous Method (triggers R#) 231 | 232 | ```]``` - Next Method (triggers R#) 233 | 234 | # Resharper Fundamentals 235 | 236 | Assuming the Visual Studio key bindings are used 237 | 238 | ```Ctrl+t``` - Navigate to File 239 | 240 | ```Alt+Ins``` - Generate Menu, allows you to generate code depending on current context 241 | 242 | ```Ctrl+Alt+Enter``` - Format the current file ( never fight resharpers formatting, configure it if you don't like it) 243 | 244 | ```Ctrl+r-o``` - Move class to another file 245 | 246 | ```Ctrl+Alt+/``` - Comment Out line of code / Selection 247 | 248 | ```Alt+Enter``` - Context aware Actions / Quick fixes / transformations 249 | 250 | 251 | # Visual Studio Fundamentals 252 | 253 | ```Ctrl+Q``` - Quick Launch, allows you to search and run any command visual studio knows about, tells you if it has a key binding, and its menu location. 254 | 255 | ```Alt+F-d-n``` - Add new project to solution 256 | 257 | ```Alt+T-n-n``` - Manage Nuget Packages for Solution 258 | 259 | ```Alt-Alt``` - Make auto complete dialogs disappear, super useful as by default esc is what's commonly used which will take you out of insert mode. 260 | 261 | # Scenarios 262 | 263 | ## Positioning 264 | 265 | For many of the scenarios in this guide, positioning your cursor in the right place is the very first task, these scenarios cover a number of ways to get your cursor to the right place. 266 | 267 | *TO BE DONE* 268 | 269 | ## Selecting 270 | 271 | Selecting text is key to many refactoring and code transformations. The following scenarios show a number of ways you can select text 272 | 273 | *TO BE DONE* 274 | 275 | ## Editing 276 | 277 | Simple editing transformations makes up a large amount of programming, both VsVim and Resharper give a lot of assistance with editing your code 278 | 279 | *TO BE DONE* 280 | 281 | 282 | ## Unit Testing 283 | 284 | Managing unit tests efficiently is key to doing things like TDD and making sure the unit test process is not painful or requires any undue effort 285 | 286 | *TO BE DONE* 287 | 288 | ### Running Tests 289 | 290 | ### Navigating to Failed Tests 291 | 292 | ### Debugging Tests 293 | 294 | ### Introducing a Type in a test and getting it into the correct project 295 | 296 | 297 | ## Refactorings 298 | 299 | ### Introduce Variable 300 | 301 | Resharper introduces a variable for a selection or whole line. 302 | 303 | Given the following code 304 | ```csharp 305 | public int Add(int a, int b) 306 | { 307 | return a + b; 308 | } 309 | ``` 310 | if we want to introduce a variable called ```sum``` then we go to the line with the return statement and position the cursor anywhere in ```a + b``` and type 311 | 312 | ```v``` 313 | 314 | This will introduce a variable 315 | 316 | ```var add = a + b;``` we now press ``` to leave the type as ```var``` and then we type ```sum``` to change the variable name and then finally to complete the refactoring at which point the code will now look like 317 | 318 | ```csharp 319 | public int Add(int a, int b) 320 | { 321 | var sum = a + b; 322 | return sum; 323 | } 324 | ``` 325 | 326 | More problematic is when we want to introduce a variable for a partial part of a statement, given the following code 327 | 328 | ```csharp 329 | public int Average(int a, int b) 330 | { 331 | return (a + b) / 2; 332 | } 333 | ``` 334 | 335 | We again want to introduce a variable for the sum part, however this time we will need to select the ```(a + b)``` 336 | 337 | So first we position ourselves anywhere between or on the brackets ```(a + b)``` then we type 338 | 339 | ```vab``` which creates a visual selection inclusive of the brackets, now we can introduce a variable with 340 | 341 | ```v```, and then we `````` through the introduce variable refactoring as in the previous example 342 | 343 | The code will now look like 344 | 345 | ```csharp 346 | public int Average(int a, int b) 347 | { 348 | var sum = (a + b); 349 | return sum / 2; 350 | } 351 | ``` 352 | ### Extract Method 353 | 354 | 355 | # Resources 356 | 357 | ## Websites 358 | 359 | http://vim.wikia.com/wiki/Vim_Tips_Wiki - so much gold here, but hard to find relevant nuggets 360 | 361 | https://vimhelp.appspot.com/index.txt - definitive list of all Vim commands 362 | 363 | -------------------------------------------------------------------------------- /vsvim.ahk: -------------------------------------------------------------------------------- 1 | SetTitleMatchMode, RegEx 2 | #IfWinActive .*Microsoft Visual Studio|JetPopupMenuView|ReSharper|dotPeek|PyCharm|Rider|Android Studio|.*GVIM|.*Visual Studio Code 3 | /* 4 | Move any short cuts to here if you want them limited to certain programs, If you use Vim bindings in all kinds of things, 5 | It can be useful to have everything global. 6 | 7 | For example https://chrome.google.com/webstore/detail/surfingkeys/ in chrome 8 | 9 | */ 10 | #IfWinActive 11 |