Resharper and ViEmu Keybindings ( and Visual Assist ) - visual-studio

With ViEmu you really need to unbind a lot of resharpers keybindings to make it work well.
Does anyone have what they think is a good set of keybindings that work well for resharper when using ViEmu?
What I'm doing at the moment using the Visual Studio bindings from Resharper. Toasting all the conflicting ones with ViEmu, and then just driving the rest through the menu modifiers ( Alt-R keyboard shortcut for the menu item ). I also do the same with Visual Assist shortcuts ( for C++ )
if anyones got any tips and tricks for ViEmu / Resharper or Visual Assist working together well I'd most apprciate it!

You can also create mappings in ViEmu that will call the VS and R# actions. For example, I have these lines in my _viemurc file for commenting and uncommenting a selection:
map <C-S-c> gS:vsc Edit.CommentSelection<CR>
map <C-A-c> gS:vsc Edit.UncommentSelection<CR>
The :vsc is for "visual studio command," and then you enter the exact text of the command, as it appears in the commands list when you go to Tool>Options>Keyboard
I don't use any of the R# ones in this way, but it does work, as with:
map <C-S-A-f> gS:vsc ReSharper.FindUsages<CR>

I use both as well, but I'm using the IntelliJ keybindings instead, so I can't speak specifically to the Visual Studio bindings. J.P. Boodhoo has some changes that he has made via AutoHotKey to provide additional Vim-like functionality to Visual Studio + ReSharper + ViEmu.
I have removed a few of the scanned keys, though, because I want to keep some of the ReSharper functionality over the ViEmu functionality, though the way I use these tools change over time as I learn more shortcuts from either ViEmu or ReSharper.

I have noticed the following, which may be useful to know. Some of the ReSharper keyboard mappings that ViEmu hoses, will work once you have a different ReSharper dialog open. I use the IntelliJ IDEA-based shortcuts, but I assume this will work similarly for ReSharper's VS scheme.
Example: ViEmu binds to Ctrl+N which R# uses for Go To Type. However, ViEmu does not bind to Ctrl+Shift+N which R# uses for Go To File. Therefore, if you hit Ctrl+Shift+N the Go To dialog is launched. You can then take your finger off Shift and hit N again and the dialog will switch to Go To Type.
This is very useful, if like me you use Go To Type a lot and don't really want to mess with the keyboard mappings.

As #Jay noted the best way is to set up custom bindings.
Here is example of bindings at https://github.com/StanislawSwierc/Profile. I created my bindings based on the previous at https://github.com/w1ld/viemu_settings

I use both plugins, but I really prefer the power of the Vi input model that ViEmu gives. I really don't miss so much the Resharper keybindings...

Related

Using intellisense and Vsvim

I recently installed vsvim and was wondering how to do a few things.
When intellisense pops in and gives you a few options,
Is there a way to choose them without using the arrow keys?
Kind of breaks the vim flow.
Thanks in advance.
If you use ALT, intellisense doesn't turn transparent!
Go to Tools, Options, Keyboard and edit these commands
Edit.LineUp : Alt+p
Edit.LineDown : Alt + n
In general no. Once Intellisense is displayed VsVim essentially backs off and lets Visual Studio key handling take over. Intellisense is one of the more important features of Visual Studio and VsVim attempts to integrate into that experience instead of taking it over.
But it's an area that's open to improvement if there is a good design around it. Is there a particular way you would like to interact with it?
You can bind the keys in visual studio for intellisense like in Jason Mirks answer, but there are problems with various other popups, especially if you have things like resharper. Quite a lot of these plugins don't respect the VS keybindings in their popups. A good way to work around this is with an autohotkey script ( which does Caps Lock as the ESC key as well)
SetTitleMatchMode, RegEx
#IfWinActive .*Microsoft Visual Studio|ReSharper
<!k::Send {Up}
<!j::Send {Down}
Capslock::Esc
#IfWinActive

Automatic Clean-Up of Code in Visual Studio 2010

I am wondering, if it is possible, to have some kind of automatic code-clean-up in Visual Studio 2010.
Especially interesting would be:
Auto-Indent
Remove tailing empty lines
Remove unused usings
at special cases, e. g. on save of the file.
I haven't found anything in the options, but maybe I was just kinda blinded... ...afaik in eclipse it was at least possible to intend on save. There should be something like that in Visual Studio?
UPDATE: Thanks for the fast replies, the thing is that I am ware of the keyboard-shortcuts (but nevertheless thanks for mentioning), but I am working through tons of foreign code by now and it would be awesom not having to do it manually for every file :)
Auto-indent can be done with Edit/Advanced/Format Document, or equivalent keyboard shortcut (Ctrl-K, Ctrl-D for me, YMMV).
Tailing empty lines I'm not aware of an automatic solution for, though there may be an extension available (or you could write your own).
Removing unused usings is a built in VS refactoring, and also available in tools like Resharper or DevExpress. (Right click code, then Organize Usings/Remove and sort.)
I'm not aware of a standard way to have these happen automatically for every document save, but you could probably write a macro or VS extension that would make this happen.
Some of the above already exist directly in Visual Studio:
Ctrl - K - D will reformat the document (Edit -> Advanced -> Format Document).
There is a refactoring that deals with using statements (right click in the code, there is an option for "Organise Using").
As for empty lines, I don't know of anything built in.
But tools like Resharper do have code cleanup capabilities that deal with all of the above and more (Resharper menu -> Tools -> Cleanup Code).
None of the above will execute on save by default, but you should be able to write a macro that runs on the save event.
You could try CodeMaid. Its an open source solution for what you are describing.
To Auto-indent you can ue ctrl+k+d pretty much like ctrl+shift+f in eclipse. But for unused usings I dont know any.

What is the difference between Ctrl+R, Ctrl+D and Ctrl+R, D visual studio shortcuts?

The question itself is in the title. See screenshots.
When I'm using those both shortcuts, my Visual Studio 2010 does exactly the same action (debug tests). However, the shortcuts are assigned for different buttons.
What am I missing?
UPDATE:
Here is my keyboard customizations in "Tools" - "Customize" - "Keyboard".
There is no difference, VS treats Ctrl+R,Ctrl+D and Ctrl+R,D as the same command. There's ancient history behind this behavior, going all the way back to an old text editor named Wordstar. Which used control key chords like that. Also adopted by Borland, a company that Microsoft was fiercely competitive with. And by me, I still use it, got a weird left pinky to show for it.
You'll have to assign a different chord for the other command.
The difference is that when using CTRL+R, CTRL+D, the test runner runs the tests with the debugger attached.
This means that you can set breakpoints in the tests and step through the code. It is very useful at times.
EDIT: I think I missed the fact that you probably know about the concept of debugging tests. As Fishermaen points out, the shortcuts might be messed up. Do you have Resharper or any other 3rd party tool that alters these settings perhaps?
Check in "Tools" - "Customize" - "Keyboard" if the shortcuts are wired up correctly.

Visual Studio (or resharper) variable and method coloring

Ok, I am not sure what the naming for this is actually called, but I would like to know if the following is possible in Visual Studio.
When I set my cursor on or highlight a variable, or method name, or string... etc, I would like the IDE to highlight all uses of it. So if I highlight variable x, then it highlights all other uses of variable x.
This is done in eclipe and Notepad++, and I have become very fond of that feature, but when I move to VS, I cannot seem to get that functionality.
I know I can use the right click and find definition, also I can use resharper to find all uses, but that is not as easy and intuitive. I am currently using VS2008, but would like it in both 2008 and 2005.
Also, if this is a feature of resharper that I just don't see, that is good too.
Thanks
With Reshaper you can press Shift+Alt+F11 when your cursor is inside a variable to highlight all usages of that variable in that file. (Then ESC to remove the highlighting)
This is not a feature of Visual Studio 2008 or previous versions. It will be a feature of Visual Studio 2010 though.
http://blogs.msdn.com/somasegar/archive/2008/12/19/code-focused-development-in-vs-2010.aspx
With ReSharper, if you're using the IDEA keybindings, use Ctrl+Shift+F7. If you're using the VS keybindings, use Shift+Alt+F11 (like Martin Harris said).
You can find the full map of keybindings here: ReSharper Feature Map
A VS plugin that I use, WholeTomato's Visual Assist X, does this. If the thing being highlighted is a variable, it will even show assignments and reads in different colors.
DevExpress Refactor or Code Rush (I have both, so I'm not sure which) will do this.
Place the cursor on a variable and hit tab; all uses of the variable that are in scope will be highlighted.
In Visual Studio, have the variable selected(you can also select methods etc.), then in the top menu go to Resharper -> Find -> Highlight Usages in File or press Shift + Alt + F11 on the keyboard.
Then if you want you can navigate down trough the usages with Ctrl + Alt + PgDn and upwards with Ctrl + Alt + PgUp.

Eclipse's Ctrl+click in Visual Studio?

After working for a few days with Eclipse Java I totally got addicted to pressing Ctrl and clicking on an identifier to go to its definition. Since then I've been looking for a way to achieve this in Visual Studio as well.
I realize VS has right click, Go to definition, and that F12 does the same. I also realize that Visual Assist does something similar with Alt + G. Yet none of these are as perfect as Ctrl + click.
I've actually tried my luck for a few hours trying to write a VS plugin to do it but didn't get anywhere in the time frame I thought reasonable for this.
Does anyone know how this could be achieved? A ready plugin? A macro of some kind?
If you use Visual Studio 2010, you can use the free
Visual Studio 2010 Productivity Power Tools from Microsoft to achieve this.
I use visual studio 2013 and 2015, I installed Go To Definition. To install this extension navigate on TOOLS -> Extensions and Updates.
I'll answer the commentors who asked about the difference between Ctrl-click and F12.
Ctrl-click workflow:
Move hand to mouse
Move mouse to hover over variable name
Other hand holds down Ctrl key while you click
Move mouse to position cursor, highlight, right-click, or whatever
Move hand back to keyboard to continue typing
F12 workflow
Move hand to mouse
Mouse mouse to hover over variable name
Move hand back to keyboard
Hit F12 key
Move hand back to mouse
Move mouse to position cursor, highlight, right-click, or whatever
Move hand back to keyboard to continue typing
If you assume the cursor is already positioned on the desired variable, F12 is better. However, that's rarely the case. Also, if you stop after this specific action, assuming you want hands back at the keyboard, the cost is the same. But if you keep in mind that you probably had a reason for wanting to go to the definition, the Ctrl-click workflow saves you an instance of moving between the keyboard and mouse.
Visual Assist supports Ctrl+Click as of June 2009 (build 1727). Activate Ctrl+LeftClick in VA Options | Advanced | General. (See the comment below.)
If you have Visual Studio 2010 you can use "Go To Definition" by Noah Richards.
http://visualstudiogallery.msdn.microsoft.com/en-us/4b286b9c-4dd5-416b-b143-e31d36dc622b
oh man, just install resharper!! (vs plugin) with it installed you just go and Ctrl + click to go to definition.
this is not the only thing resharper does, try it out free!!!
I use the built in options (F12, Right-click -> Go to definition) but I know a lot of the guys at my company use Resharper and it definitely has this functionality.
Microsoft released a Visual Studio 2010 extension named "Productivity Power Tools" which now adds Ctrl+Click functionality. So if you're like me, and hate installing third-party addons, you can now have the same functionality!
Another option with VS (besides F12 and right-click > Go to Def) is add the code definition pane (View > Code Def Window). This is essentially another editing pane that shows the code for the current symbol - no need to Ctrl-click or anything. I keep it pinned to my secondary monitor. Any time I need to see the implementation for a symbol I just click it and look over.
Another nice thing about F12 is you can also do ShiftF12 to find references to a symbol and F8 through them. The two go together like love and happiness.
I prefer to bind Go To Definition to CtrlD. This makes it extremely easy to use either with both hands on the keyboard (CtrlD to go tho the definition of the symbol under the cursor) or one hand on the keyboard and one hand on the mouse (Click on a symbol, then CtrlD).
All in all, both VS and Eclipse have weird key shortcuts.
I just had to respond, too: F12 is far too right on the keyboard and you have to leave the the mouse right hand for the keyboard to use it. As a long time VS user I just didn't find it until I searched for the Ctrl+Mouse equivalent in Eclipse. It's completely borked. OK? No need to argue. (The same goes for F3 in Eclipse going for definition. ???? Why the face??? It's FIND NEXT for Pete's sake. But this can be removed after mastering the Eclipse keyboard shortcut system in the course of a few years.)
Anyway, as has been said here before, Microsoft has already understood this can be an issue for new programmers coming in from Eclipse, so they provided the Power Tools (I followed the link up above).
http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef/
If you are using Visual Studio 2017, you can use Productivity Power Tools 2017
I don't work in VS much, so I haven't used it, but I've heard incredibly good things about Resharper from everyone I know who does. Everyone has told me it's worth every penny, and significantly improves efficiency in Visual Studio. I think it has a feature like what you're looking for, along with a TON of others.

Resources