"Keep Tabs" setting not working in Visual Studio 2019 - python-3.x

I've been having a problem in Visual Studio 2019 where the program enters tabs as four spaces. This is annoying, since I have to hit backspace 4 times to erase an indent, and I need to use arrow keys 4 times to navigate an indent.
This used to work fine, but I had to uninstall and re-install Visual Studio to fix another problem (it kept running old versions of my code and wouldn't run the new version), and ever since then, I haven't been able to get it to work.
I went to settings, and selected 'keep tabs', but it still replaces it with four spaces every time i hit the Tab button. Interestingly, when I start a new line, I can navigate and backspace normally, but if I enter any more tabs, they are replaced with 4 spaces.
I've tried looking around, but I can't seem to find anything that addresses my issue. Can anyone help?

How to fix problem in Visual Studio with "Keep tabs" not working.
I also had this problem with tabs being converted to spaces.
I checked Tools>Options>Text Editor> (All languasges as well as c/c++) >Tabs> and assured that "Keep tabs" was selected.
After some trouble shooting I found that only one file had this problem (file1.h).
I created a new empty file (file2.h) that worked correctly.
I took the statements from file1.h and divided them into small block. Then I moved the blocks to file2 and after each block I tested file2.
After a few block suddenly file2.h failed. When I removed the last block from file2 the problem was solved.
My conclusion is, that the source code contained some invivisible code, that made the text editor turn off the "Keep tabs" setting.
I have seen comments about a setting "Use adaptive formatting" that might be relevant. So far I have turned this setting off.
My setup is Visual Studio Community 2019 v 16.4.4 with an Arduino plug in from Visual Micro v 1912 28 2.
/Steen

Disable the checkbox: Tools->Options->Text Editor->Advanced->Use Adaptive Formatting
You will still need to delete the spaces it inserted for you, but will retain tabs afterwards.

Also note that Visual Studio 2019 now uses and prioritizes .editorconfig files over the Tools -> Options -> Text Editor settings.
If you have tried the above answers and still cannot get your indent and tab settings to work, then look for an .editorconfig file anywhere in your project's directory structure.
For instance in my project Angular CLI created one for me when I initialize a new ng project in my .net Web API directory structure. All my *.ts files were not cooperating.
I had to edit the .editorconfig file to look like this in order to get 4 space indent and tab instead of spaces. Once I did that, Ctrl + K + D (reformat) started working again:
# Editor configuration, see https://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = tab
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
[*.ts]
quote_type = single
[*.md]
max_line_length = off
trim_trailing_whitespace = false

Related

Forward slash key not working in VS2019 code editor

Since a few days (I don't know exactly when it started) the forward key in VS2019 is not working in the code editor. No matter how many times I press it, it doesn't do anything.
It also doesn't work in the seach box in the menu bar (labelled 'Search (Ctrl+Q)') nor in the search box which appears with Ctrl+F.
It does work in other places, like the solution explorer search box (Ctrl+;) and in the resource editor.
The forward slash is working in any other application that I tried (including Visual Studio Code and MS Excel). The question mark (Shift+/) is working everywhere, including in the code editor window. Even AltGr+/ is working (producing the Spanish upside down question mark).
I tried all other keys, including the AltGr combinations. They all work fine. Keyboard layout is US International.
The foward slash key doesn't work in the code editor when typing it on the laptop keyboard, and doesn't work when typing it on an external keyboard, or via an RDP session.
I am running Windows 10 Pro 64-bit, version 20H2, build 19042.685. System is up to date.
Visual Studio Professional 2019, 16.8.3, also up to date.
What is causing the forward slash key to fail?
How can I solve this problem?
(Too long for a comment.)
The OP indicated that the problem was resolved after resetting the keyboard shortcuts, which suggests that / was set as a keyboard shortcut either by accident or perhaps by an installed extension.
However, the question remains in such cases of how to identify what a particular keyboard shortcut is assigned to, in order to turn off just that one shortcut as opposed to resetting all.
Visual Studio does not appear to provide a place to see the list of all active keyboard shortcuts. An alternative is to go to Tools / Import and Export Settings / Export Selected / All Settings and save a .vssettings file with all the current settings. That is a plain text file with extended XML sections, and the keyboard shortcuts can be found under the following node (reformatted for readability):
<Category name="Environment_KeyBindings" ... >
<Version>16.0.0.0</Version>
<KeyboardShortcuts>
<DefaultShortcuts>
<Shortcut Command="View.ViewCode" Scope="Global">F7</Shortcut>
...
</DefaultShortcuts>
<UserShortcuts>
...
</UserShortcuts>
</KeyboardShortcuts>
</Category>
One of the <Shortcut> lines would have been listing / before the reset, and the Command attribute on that line indicated the assignment, so that it could be located and turned off individually in Tools / Options / Environment / Keyboard.
#dxiv Your comment made me check the shortcuts. Tedious job, scrolling through those hundreds of options). Nothing. Then I clicked the Reset button. That solved the problem.
In my case, the CodeRush extension was the guilty party. "Selection comment" gets set to use / upon installation. WTG DevExpress ......
https://docs.devexpress.com/CodeRushForRoslyn/120205/coding-assistance/selection-tools/comment-uncomment-selection
Update:
Also adding a screenshot of it in VS 2022 to help people find it:

How to enable word-wrap for editor in Android Studio on MacOS

Recently the Android Studio 3.5 updates and now Android Studio 3.6, the editor window does not wrap the text so some lines are long and go off the right of the screen. I don't want to scroll left and right all the time, so would like the text to autowrap. I've read many posts on the issue but nothings has solved it.
I've tried going to
Preferences -> Editor -> General and enabling soft wraps there, but that hasn't helped.
I tried adding *.java to the soft wraps files but that didn't help.
The only thing that works is selecting View -> Active Editor - Soft Wrap. That formats the current editing window with auto wrap, but each time I open a new java file auto wrap is not enabled I would need to enable it again. This is so frustrating and was never an issue before Android Studio 3.5. Any help would be appreciated.
I had the same problem, and my solution should work for you. The delimiter in the soft-wrap file list is a semicolon, not a comma: change your comma to a semicolon.

Maddening auto-format behavior with Visual Studio 2019 / Resharper that I cannot disable

This started happening for me in Visual Studio 2019 but does not happen in 2017. I cannot figure out how to stop it.
Something I do all the time is make use of Resharper's reformatting. Suppose I have little block of code like this:
Scan = scan;
Target = target;
IsDone = true;
ShouldAlign = false;
I want to align it up to look all nice and neat. So I select my block of code and I either use the menu or a keyboard shortcut to invoke Resharper's autoformat to line up the equals signs. Voila! Looks great, Here is the reformatted code, exactly as it appears, right after I've reformatted. Note the code is still selected:
But then all I have to do is I click anywhere else in the whitespace of that document, and Boom! Everything gets undone
It is as if VS2019 runs its own "Format Selection" command when I click away But I never did that. (but if I manually do, it has the same effect)
However if instead of just clicking away on the whitespace I, click the menu area of Visual Studio and then click the document whitespace, no problem. No reformat.
Just now I've just finished comparing Visual Studio 2017 and 2019 editing settings side-by-side next to each other. I've compared every single edit/formatting/spacing setting I can possibly find. Both Visual Studio's and Resharper's. They are identical except in those few cases where VS 2019 has some new setting that 2017 did not.
This still happens even when all of VS2019's "automatically format" settings are off
I'm asking the same question of the Resharper folks but I think it has to do with the interaction of the two.
Is anyone else seeing anything like this? It's driving me nuts.
After several hours of this, I have finally discovered that that problem was neither Visual Studio nor Resharper. It was actually a THIRD extension I use (also very common) for C++ files called Visual Assist".
VA has its own "format after paste" option. I am guessing that it must detect the reformat/click away as a "paste" operation and it reformats it according to Visual Studio's settings.
Once I disabled that in single, Visual Assist option VS2019 (as I apparently already had in 2017) everything worked well.

Using tab identation instead of spaces on Android Studio

Just trying to use tab-indentation on Android Studio 2.2.2
I followed the instructions I found on this thread:
Android Studio "This file is indented with tabs instead of 4 spaces"
But these instructions work only for new documents I create after setting that configuration but for previously created documents the space-indentation persists.
How can I configure all the files on my project to tab-indentation? for files before and after the tab-indentation configuration on the link above?
After changing the settings you have to reformat your codes, you can do this one by one by opening the file and pressing (Command + Option + L) shortcut or right click on your src folder and selecting Reformat Code option:
You can check the result by selecting View -> Active Editor -> Show Whitespaces from the menu:
which would be something like this:

Resharper 5 vs 6

Back when I had ReSharper 5 my files would have all kinds of syntax highlighting and a bar next to the scrollbar to the right. It was wonderful because it would highlight redundant imports and possible code smells, as well mark things in the bar next to the scroll bar.
With ReSharper 6 I don't have any of that. I have to actually have cursor on what I want to change and wait for the pencil or light bulb to show up. Is this how ReSharper 6 is by default or do I have to reinstall it?
First make sure ReSharper is acutally activated. If it is, there should be a ReSharper top level menu entry in Visual Studio at the top.
If it is, make sure "Enable Code Analysis" is turned on in the ReSharper settings.
If it is not, enable ReSharper in the Visual Studio settings (Tools->Options). There should be an extra entry "ReSharper" in the list on the left side. Click the "Resume" button.
If you don't have such an entry in your Visual Studio settings, ReSharper is either not or not correctly installed.
Maybe the settings were not taken from the version 5 folder to the version 6 one. Try the following:
Make sure you close Visual Studio.
Go to:
Note: this folder is from a Windows 7 machine, since you didn't provide information on which version of visual studio you are using I'm putting 'x'
"c:\Users*your user*\AppData\Roaming\JetBrains\ReSharper\v5.x\vsxx.x"
In there you'll find a UserSettings.xml file open it for edit.
Look for the "SeverityTable" node. Select it and copy it.
Paste it on the same file that you'll find on the "c:\Users*your user*\AppData\Roaming\JetBrains\Resharper\v6.0\vsxx.x" folder. I recommend making a backup of the file before doing that.
Reopen visual studio. Resharper should be indicating all the recommendations and smells as it did before you updated it.
Hope this helps.

Resources