Visual Studio 2022 quick action from constructor parameter to auto field creation not adding space - visual-studio

In VS 2022, when I press Ctrl + . on a constructor parameter and select "Create and assign field/property", the resulting code is missing spaces around the assignment operator = like this:
_logger=logger
It's not a big deal obviously but annoying to fix manually for unified formatting (defeats the purpose of quick action). Is there a setting somewhere that can fix this?

If you want to avoid to reset all settings: this behavior is controlled by the following setting:
It is set to Ignore spaces around binary operators by default; if you change this to Insert space before and after binary operators the space will be added.

You can reset your Visual Studio settings:
Tools => Import and Export Settings => Reset all settings
This will reset all your settings (you can create a backup in the process). After the reset, spaces will be back to normal.

Related

Visual Studio 2013 IntelliSense Subword Navigation and Completion

I am curious if VS2013 has the possibility to make it's intellisense auto-complete a little more effective.
I am used to have classes like MyClassInCamelCase and MyClassAgainInCamelCase even MyClassYetAgainInCamelCase. The way intellisense works for me is that I type My and I get a list of the 3 possible classes that match this word. But things will be a lot easier if I could make it like a command prompt and hit some special key that will autocomplete the word until the next CamelCase word, so I could get "My", then "MyClass" and then the next character I type can define a unique word (or just hit ; for example and auto-complete the current selected word on the list).
Also, the possibility to navigate between CamelCase words will be of great help.
Does anyone knows if this is a hidden feature or something? Or if there are external plug-ins that can make this possible?
This might not directly answer your question, but note that with camel-cased type names, you can do better than to start typing the beginning of a type name (My):
Typing an enclosed part of the name:
Again will suggest MyClassAgainInCamelCase and MyClassYetAgainInCamelCase.
Yet will suggest just MyClassYetAgainInCamelCase.
Typing just the capitalized letters:
MCY will suggest MyClassYetAgainInCamelCase.
Both of these shortcuts can be combined, btw.
I think the hotkey combination is Ctrl + Space to open Intelisense, than Tab, Enter or Space to insert.
There is a complete word option in the Intelisense settings, check if that's toggled on.

How to make Intellisense in Visual Studio 2012 not to substitute text right to the cursor?

While programming I often realize that I need to add something before already typed code. For example I type the name of the variable:
input[0]
and then I realize that my array is of type string and I need to convert it. So, I move to the beginning of the word (with Ctrl-Left Arrow) and start typing
Convert.To|input[0]
with pipe used to show the position of my cursor. I get some suggestions from Intellisense, including the ToInt32() method I am looking for. But as long as I confirm this suggestion with Tab or Space, I get the following:
Convert.ToInt32(|)[0]
So, the text from the cursor position to the end of the word is substituted with suggestion, and this is definitely not what I want.
This problem is not specific for VS 2012 and might be due to some extensions I have installed, but my attempt to pursue its origin did not yield anything. I have following extensions installed: ReSharper, PowerCommands, Productivity Power Tools.
If you are entering an unrelated expression before an identifier, add a space before you start typing the new expression. This will prevent the completion from replacing the existing identifier.
For example, if | marks the caret, the following scenario would avoid the problem you are facing.
Convert.To| input
This code completion feature is designed to prevent the insertion of incorrect identifiers. If Visual Studio behaved like some other IDEs I know of, using the code completion feature in your original example would result in the insertion of ToInt32input, which would never be valid.
If you are interested in additional thoughts regarding this feature in general, I have described this as the Extend (default for Visual Studio) and No-extend (default for NetBeans, Eclipse, and others) modes in my blog article Code Completion filtering, selection, and replacement algorithms.
A two years later answer. But it might still be useful for some.
What helped for me in VS2015 (which might also work in VS2012) is to add the a space character to the list of 'Member List Commit Characters' in the Intellisense settings.
After this the characters after the cursor are not removed by an auto-completion.

Share All Resharper code formatting/inspection options

As denoted in This Article ReSharper's .sln.DotSettings file contains only those settings which values changed from default ones. Is there a way to store all the code editting and code inspection settings in a team-shared layer, regardless of the value being changed or default?
The only way to do this I see is changing each and every value and switching it back (so all of them end up in .sln.DotSettings file), however this seems to be quite a time-consuming task.
The problem I'm trying to avoid is as follows:
Suppose a team has 2 developers, say Jessika and John, and they decide that they are OK with Resharper's default to prefix private fields with with an underscore:
int _myPrivateField = 1;
So they are not changing the "Instance fields(private)" setting under "C# Naming Style" section and check in the .sln.DotSettings file.
However, when Jessica checks out the source code on her home laptop it Resharper still suggests using
int myPrivateField = 1;
because her computer has its setting changed to have no prefix, saved as "Save to this computer". As denoted in Resharper's docs if a "This Computer" layer has a value for a setting, whereas the other layers don't the value will be applied (see the middle green setting in this picture: http://blogs.jetbrains.com/dotnet/wp-content/uploads/2012/08/layers3.png
Regrettably, at the moment we can offer no option other than changing options one by one and saving them in the requisite layers. We are aware that this approach is inconvenient, and are in discussions as to how to best handle this.

Vim Saving Macro to File. Encoding Issue

I'm trying to save a macro to the file I'm editing.
All goes well until I close and reopen the file. When I reopen the file, the pasted macro
<80><fc>^B Setup^M<80>
has become
■üSetup^M■
I assume this is encoding related but it's beyond me on how to resolve it.
Following are some settings that might be relevant:
fileformat=dos
fileformats=dos,unix
fileencoding=latin1
fileencodings=ucs-bom,utf-8,latin1
encoding=utf-8
Does anyone have an idea what I need to change to make it work?
Edit
I had no idea where the <80><fc>^B sequence was coming from.
It appears to be inserted into the macro when I type //***** Setup with the SHIFT key pressed up until the S from setup. The macro gets pasted as //*****<80><fc>^B Setup
Note 1: I use an Azerty keyboard. For the keys / and *, I need to press the shift key.
Note 2: A solution is to not hold the SHIFT key when typing the space character between //***** and Setup. Holding the shift key mearly has become an automatism when typing that pretty much used sequence.
you are using the gui with -W option? Then read that question. It is really related to it.

Using macros without the escape key

I am trying to use the a macro in xcode.
I type in a then hit escape and select it.
This is annoying because I have to hit page up 5 times to get to the a.
Is there a different key combination that will just let me use the a as typed without having to select it?
Have you changed your XCode defaults? I'm using 3.1.4 and I don't have to hit page up. Here are my exact key presses:
a
escape
enter
I can also hit escape first and start typing the macro name.
Edit: Argh! Your demon has infiltrated my XCode! ;) If I auto-complete some things, they become sticky as the new starting "a" macro--I can't even backspace and type "a" to use the first "a" macro. Each file has it's own persistent memory too, so switching files changes the default. Using a method or property or any other parsed symbol seems to have priority over the macros so the default will never go back to the initial "a" macro once you auto-complete a parsed symbol.
Pretty weird bug. I must not have seen it because I don't use macros much.
The only way I found to fix this is to change the "a" macro to some other auto-complete such as "ai". That way when you type "a" "escape", typing "i" next will select the macro you want even if there's a bad sticky default.
Start with this reference http://mcdevzone.com/2009/04/09/useful-xcode-tricks/
Then edit "~/Library/Application Support/Developer/Shared/Xcode/Specifications/TextMacros.xctxtmacro/Contents/Resources/ObjectiveC.xctxtmacro" and change the "CompletionPrefix = a;" to some other prefix.
When you restart XCode, the new prefix will work in place of the old "a" macro.

Resources