Visual Studio 2013 auto indent - visual-studio

In Visual Studio 2013, under Tools > Options > Text Editor > File Extension, I have set three file extensions, namely .cginc, .compute, and .shader (these are Unity3D shader files) to use Microsoft Visual C++ for auto formatting.
Sometimes auto indent (for curly braces) works, and sometimes it doesn't...I can't find any rhyme or reason for this. When it doesn't work, it starts every new line flush to the left.
I Google around every couple weeks and can't find an answer.
Does anyone know any setting to make auto indent work consistently?

Try this:
Tools -> Options -> Select the language of your choice (Expand the menu) -> Select Formatting (Expand this sub menu) -> Select Indendation
Once you have selected Indentation, on the right are options displayed - Check/Tick the option: Indent Braces.
Note: You may also format the entire document/file using the shortcut Ctrl+K+D

Related

How to turn off auto indent in Visual Studio 2019? (not VISUAL STUDIO CODE)

I usually use comma , to set the same variable type like the gif above.
But a problem is when I hit Enter after write second variable, the VS breaks the line automatically.
As a formal Atom user, it's a bit tedious because in Atom it doesn't break the line whatever the indent number is. (My current indent number is 2.)
I changed and tested it all of the options inTools > Options > Text Editor > Basic > Tabs, but none of these turn off the breaking line. Even disabling pretty listening won't work.
How do I turn off this feature?
Judging by the glimpse of Intellisense and the fact that Enter auto-formats, it looks like you're editing a JavaScript file.
To disable auto-formatting after hitting Enter, go to Tools > Options > Text Editor > JavaScript/TypeScript > Formatting > General and toggle Format completed line on Enter to unchecked:
The accepted answer doesn't work in Visual Studio 2019 with Visual Basic. These options on the image aren't even shown in the Options for Basic.
However, when the Pretty listing option is turned off, this behavior ceases.

Make all opened document tabs visible

I would like to see all files or documents I've opened in Visual Studio. I do not want them to be auto hidden or hidden on overflow.
How can I achieve it?
One of the built-in option to do so: use pinned tabs.
http://dailydotnettips.com/2016/01/21/persevering-and-separating-the-pinned-tabs-in-visual-studio/
If you don't want to read a external page just for setting:
Tools -> Options -> Environment -> Tabs and Windows -> Show pinned tabs in a seperate row
It's not completely what you want, but it's free and may be useful.
Maybe it's not exactly what you search, but here is a way to at least get a second row for pinned tabs.
Effectively get you more space for opened files:
Tools -> Options -> Environment -> Tabs and Windows -> Show pinned tabs in a seperate row
Visual Studio has this extension taken from msdn.microsoft.com tested and worked
Simple installation: download, doubleclick to install, restart VS IDE. Then open all the tabs you want they all will be displayed and No hidden.
https://visualstudiogallery.msdn.microsoft.com/EBF6137E-AA2D-4DC9-860A-F04168F11CD7
Dung Le.
It's worth noting that starting in VS 2019 v16.4, you can now have "vertical tabs" which will list all open tabs vertically, making it easy to see all open files.
https://learn.microsoft.com/en-us/visualstudio/ide/customizing-window-layouts-in-visual-studio?view=vs-2019#vertical-document-tabs
In Visual Studio 2022, this issue now has a native solution. Go to Tools -> Options -> Environment -> Tabs and Windows -> Show tabs in multiple rows. Excess tabs will be shown on additional rows. There doesn't seem to be a limit on how many rows this can use.
Another relevant option that some may find useful; you can choose "Show invisible tabs in italic in tab dropdown menu". The dropdown button is only visible when you hover your mouse near the end of the row of tabs. Showing invisible windows in italics makes it easier to identify windows that are only visible in the overflow menu.
For those using Visual Studio 2022, check the "Show tabs in multiple rows" setting in Tools > Options > Environment > Tabs and Windows section.
For Visual Studio Code
If you want to see all the opened tabs,
you can simply on wrap tabs option in the VS Code settings
settings > User > Workbench > Editor > Wrap Tabs

javascript visual studio 2013 indentation

I started playing around with javascript on Visual Studio 2013 and I couldn't figure out why it is not automatically positioning the cursor to the correct indentation level, instead always resetting back to the head. For example:
function foo(y) {
var f = function bar(x) {
|<-- cursor should be here, but ends up
|<-- over here
}
Does anyone else see this and how do you change it?
I have the typescript, nodejs plugin installed and that's about it.
With a bit of research, things started working for me. First check that, Tools -> Options -> Text Editor -> Javascript -> Tabs -> Indenting is set to 'Smart'. Next restart VS. For me restarting was important since, apparently, my file had some mixed line-endings and that was throwing off the indentation engine. Hope this helps someone.
In my case, the whole javascript formatting stopped working for every file, I could play with language options and restart VS, nothing helped, until I unchecked:
Tools -> Options -> Text Editor -> JavaScript/TypeScript -> Language Service -> Enable the new JavaScript language service
The editor returned to old school javascript formatting, which is sufficient for me.
I'm not sure if this applies to Visual Studio 2013 (the original question), but in 2015 at least, you can select the text in your JavaScript file you want to format, right-click, and then choose "Format Selection". There's a keyboard short-cut as well (Ctrl-K, Ctrl-F).
If you already have Tools -> Options -> Text Editor -> Javascript -> Tabs -> Indenting set to 'Smart', then try setting this option (the Indenting setting) to 'None' and click OK.
Open the Options back up and, set Tools -> Options -> Text Editor -> Javascript -> Tabs -> Indenting back to 'Smart', click OK.
Close and reopen the file you were working on.

Visual Studio - "{ }" settings

Seriously, I don't know what to google. Here's the thing, I like this Java-like code writing:
if (condition == true) {
doSomeStuff();
}
But VisualStudio "helps" me with its own "style", which I don't like and I am unable to change (after rather big time of desperate checking all settings :/)
if (condition == true)
{
DoStuff();
}
I obviously want the "{" char to be in same line where condition is ...
I am using MS Visual Studio 2010 professional.
Go to Tools > Options > Text Editor > [Language, i.e.: C#] > Code Style > Formatting > New Lines
This is where you can set your new line options for braces.
See the image below for more clarification.
Tools -> Options ...
alt text http://img6.imageshack.us/img6/158/capturejo.png
Text Editor > C# > Formatting > New Lines > New line options for braces
Uncheck Place open brace on new line for control blocks.
Probably want to uncheck put else on newline as well.
This is for Visual Stuio 2008, so I'm not sure that it's exactly the same in VS 2010:
Go to the Tools menu and open Options. Make sure that the Show all settings checkbox is checked. Open the Text Editor node and then the node for the language you want to change the setting for. Open the Formatting node and select the New Lines node. Here you can change when new lines are added to the code.
After installing Visual Studio I go in there and uncheck every option in the New Lines section.
Worth knowing is that Steve Horn's (and others) answer works even for other languages as they seem to appear to not have the same settings-layout. I did the changes as described in his post and it worked for my C++ projects as well.

Visual Studio Macro to Indent C/C++ Braces

We have an old project that we maintain that uses brace indenting. Rather than having to change my Visual Studio options every time I switch projects, I'd like to be able to do this quickly and easily.
I'm trying to write a macro in Visual Studio to turn Brace Indenting on and off.
The checkbox is under Text Editor -> C/C++ -> Formatting
Indentation: Indent Braces
This doesn't work:
DTE.Properties("TextEditor", "C/C++").Item("IndentBraces").Value = True
I get "Value does not fall within the expected range."
Any ideas? I haven't been able to find anything on this.
I found the following is the correct macro code to make this work
DTE.Properties("TextEditor", "C/C++ Specific").Item("IndentBraces").Value = True
see: "Determining Names of Property Items in Tools Options Pages" which is only mildly helpful in this situation but gave me enough of a clue to find it.

Resources