Can visual studio code block modifications like vim? - visual-studio

Is it possible to lock files in visual studio code? Similarly to what you do in vim where you have to press "i" if you want to modify files I'd like to be able to keep the files locked and then press a key that allows me to modify them and then lock them again. Is it possible to do so in visual studio just like in vim?

It looks like you're looking for a "modal editor" interface.
If using actual Vim keybindings and commands would work for you, then consider adopting Vim for VS Code, which emulates most of the Vim UI inside VS Code.
It should give you the best of both worlds.

Related

Refactor on save in Visual Studio 2019

I love Prettier for VS Code. I want to do similar things in Visual Studio (2019).
It now has 'Wrap, indent, and align parameters or arguments' for example (https://learn.microsoft.com/en-us/visualstudio/ide/reference/wrap-align-indent-parameters?view=vs-2019); and I'd like to do this automatically whenever I save the file.
Does anyone know if this is possible? Or if there's a free extension that can do this?
Mads Kristensen (a Microsoft employee who makes scads of Visual Studio extensions and teaches you to too!) made a JsPrettier extension for "classic" Visual Studio (ie, not VS Code):
https://github.com/madskristensen/JavaScriptPrettier
It does not format on save if you set that up in its settings.
If it's literally Prettier in Visual Studio that you're after, this isn't a bad option.
I don't know of a free plugin but you can get quite a long way towards this with some muscle memory and the built in autoformat command.
CTRL+E, CTRL+D, CTRL+S
will do code indentation and formatting, and save the file.
If you have Resharper (sorry), there's a configurable code cleanup tool which will do what you want and CTRL+E, CTRL+F, CTRL+S will do the cleanup and save.
The Format document on Save VS extension does exactly what you want, with one exception. It automatically runs Visual Studio's code cleanup command on save.
Visual Studio's code cleanup commands covers many code style preferences and can be configured with a .editorconfig file. Unfortunately one thing that is not supported by VS yet (not counting Resharper) is line wrap preferences. There is an open ticket for this: dotnet/roslyn#33872
If and when Roslyn supports line wrap preferences (presumably as a new .editorconfig preference), then Visual Studio code cleanup will enforce it and the extension will apply it on save.

Forcing Visual Studio to set "Insert Tabs" from a script

I would like to write a script to force Visual Studio 2015 to "Insert Tabs". The idea is that this script would be pushed out by our IT department and run on Windows startup to ensure that everyone is consistent. If you hate tabs, pretend I'd like to write a script to set "Insert Spaces".
The obvious way might seem to set HKCU\SOFTWARE\Microsoft\Visual Studio\14.0\Text Editor\CSharp\Insert Tabs to 1. This appears to do nothing, probably because we are using Synchronized Settings (https://msdn.microsoft.com/en-us/library/dn135229.aspx). What can I do about this, short of writing an extension to Visual Studio and pushing THAT out.
You may consider using an extension like EditorConfig or Rebracer that apply editor settings from a shared per-solution file.

Visual Studio code completion like ctrl+k in netbeans?

My question is there code completion for Visual studio like in Netbeans where you cycle the buffer with ctrl+k, when you type something?
There's now a nice extension called Simple Autocomplete which adds one command simpleAutocomplete.next that you can map to a shortcut of your choice.
No, there isn't a similar feature in Visual Studio.
The traditional Visual Studio autocomplete is using intellisense.
When you start typing, intellisense may bring up a drop down with suggestions. In that case you can tab to complete using the current suggestion or use the arrow keys to choose another.
Ctrl-Space (or Alt-Right arrow) will bring up this intellisense menu if it's not up.
I find it does a pretty good job overall.
Some extensions like Resharper or Visual Assist offer their own code completion or other similar features (like Suggestion List for Visual Assist).
I know it's been ages since I asked this question but I found the next best thing to do this. What I would suggest is to use VsVim extension and to use Vim's anyword completion; however, in order for this work, what must be resolved is the keyboard shortcuts that conflict:
Go to "Tools options" in Visual Studio.
Then go to VsVim category(alternatively you can search "VsVim" and
should bring the options) and click keyboard.
As far as I know vim deals with this type of completion with these keys
CTRL+P and CTRL+N so what we do is to let Visual Studio give up
these keybindings and let VsVim deal with it by Selecting from the drop
down of the keys(CTRL+P and CTRL+N) and let it be "Handled by VsVim".
I hope this has helped someone out.

IntelliJ and Visual Studio select and rename a variable in multiple places by a shortcut behavior as 'Ctrl+D' in Sublime?

Because of the lack Intellisense in Sublime, I prefer to using Visual Studio to code C# and Pycharm to Python.
ctrl + d in Sublime can select mutiple same word in text. So I can alter the selections on same time. It is convenient to alter the name of same variable in a function. How can I do that in my other editors?
The Ctrl-D multiple selection tool is one of its greatest features of Sublime Text 2 and is sorely lacking in other editors and IDEs.
Visual Studio doesn't have it built-in but there's a MultiEditing plug-in for it.
IntelliJ, which PyCharm is based on, doesn't have it either but it's apparently being planned for a release that should be out soon. See this blog comment (and the link in it) for more.
Meanwhile, you can use the rename refactoring tool in Resharper (for Visual Studio) or in PyCharm. It's not the same as multiple selections but is very useful functionality in its own right.
A nother IDE that does support it is Webstorme - alt+j. you can read the stackOverflow discussion about it here : How can I select next occurrence in IDEA editors
I just tested it on Webstorme10, and it works perfectly, just like in Sublime.
Try ctrl + h. It is the standard shortcut in many editors for replacing text.

Ctrl+' (Apostrophe) Refactor! binding doesn't work when Notepad++ is open?

This is a really odd one that has been annoying me for some time, I use CodeRush and Refactor Pro at home and at work, since the switch to Visual Studio 2010 I have been unable to use the keyboard shortcut (Ctrl+') for the Refactor/CodeRush context menu:
For a long time I blamed VS2010 or CodeRush/Refactor! Pro for the issue and just worked round it with the mouse. At some point in time I realised that if Notepad++ was open the shortcut key didn't work.
Depending on what type of file is loaded in Notepad++ alters the effect; for example, if I have an XML/HTML/XAML file open a tag and all of it's children are removed.
I have just tried Notepad++ v5.8.6 with some source files opened and IDETools 10.2.4 in Visual Studio 2010, Windows 7 and everything seems to work fine - the CTRL+' shortcut works as expected. Probably you might want to change the shortcut to something similar like CTRL+1 in the DevExpress\Options\IDE\Shortcuts options page.

Resources