Is there any way to make visual studio dim or hide/show on demand logging lines of my code?
We use a lot of logging in our project and it's harder to read code like this.
I would like it to be like this, for example:
Unobtrusive Code extension worked for me for Visual Studio 2019. It dims the opacity of log lines (and comments, which I disabled - I enjoy reading my comments). He did a quick update for the nuget package, and it works great.
https://marketplace.visualstudio.com/items?itemName=niklaskallander.UnobtrusiveCode
I use this. Hoping one day they will add color customization and line selection regex options as well:
https://marketplace.visualstudio.com/items?itemName=ElmarXCV.GrayLogLines
There is no way to do this from the standard Visual Studio IDE. In order to do this you would need to define a custom extension which recognized lines like this, tagged them with a specific format and have that format be colored a lighter color in the IDE
a "hackier" way would be to wrap all logging in a preprocessor directive like
#if DEBUG
Log.Info(........)
#endif
Visual-Studio will "dim" the code inside.
and have some kind of config header where you
#define DEBUG 0
Not the prettiest but its nice if you don't want debug code compiled into your Release binary
why don't you put your section within #region tag.
E.G:
#region Put some region name here for your reference
Your Code / Comment / Whatever
#endregion
Related
I have a scss file that I call in
#import ..mixins
but when I try to call in methods from the mixin that is defined like this
#mixin myFunction($param1, $param2){
style:$param1
style:$param2
}
Phpstorm just gives a hint like
myFunction()
without any parameter information. Has anyone found any solutions to this?
Unfortunately it's not yet supported in current versions on PhpStorm/WebStorm (stable 2016.3 and upcoming 2017.1).
Watch these tickets (star/vote/comment) to get notified on any progress:
https://youtrack.jetbrains.com/issue/WEB-10806
https://youtrack.jetbrains.com/issue/WEB-24715
I came here searching for this myself, and it isn't supported even in 2018.
It's not going to give you hinting apparently, but, for often used mixins you can create a live template (snippet) with variables.
In your case:
1) - Navigate to Settings: File>Settings>Editor>Live Templates. Then click the '+' to add a new 'snippet'.
#mixin myFunction($$param1$, $$param2$);
The extra $ are for naming vars in Live Templates.
OR,
2) - Highlight the snippet of code to use for a new Live Template. Then press CTRL(CMD)-SHIFT-A and search "Save As Live Template". Double click or press enter to do '1)' much quicker if the code is already present.
That's a dirty workaround in the meantime.
What PHPStorm does support is: when you #include myMix, the hint will expand if you use the up, down arrows. Still not hinting, but almost.
Im learning angular and it would be nice if i could have $ the dollar sign, formatted so its maybe red since it would make reading angularjs code much easier.I am using visual studio 2013.
To recap.I want the dollar symbol in javascript files to be of color red.
Since this isn't really a question, add your suggestion/request to http://visualstudio.uservoice.com.
If you want to implement this yourself you would need to create your own intellisense settings for JavaScript, which I'd suspect is something you probably don't want to do.
I have exactly opposite problem to one described here. In my case Visual Studio inserts using directives inside namespace and I want to prevent this. I did try to uncheck Resharper option:
Languages -> C# -> Formatting Style -> Namespace Imports -> Add using directive to the deepest scope
And it didn't help. Also I tried to temporary disable the Resharper. Still same issue.
Btw, I have StyleCop and StyleCop+ installed as well. Maybe it is causing the issue.
So right now when I go and Add New Item -> Class - it will create new code file with using directives inside namespace. How to change this?
Have you replace your class template file with one that has one or more using directives inside the namespace declaration? If so, you're probably seeing the result of an interesting bit of C# plugin behavior: a newly added using directive is placed after the last recognized using directly already in the file, regardless of where that is.
If I am editing a .js file in Sublime Text 2 that makes use of a library defined in a separate .js file, is there a way to support tab completion of objects/functions defined in the external library file?
Something analogous to the following from Visual Studio:
/// <reference path="/js/some-library.min.js" />
which enables IntelliSense over the library/plugin code.
I haven't tried it myself yet, but there's SublimeCodeIntel: https://github.com/Kronuz/SublimeCodeIntel#readme
The OP in this thread: http://www.sublimetext.com/forum/viewtopic.php?f=3&t=5319 seems to be complaining that it's pulling suggestions from outside the current file, which may mean it's doing what you want.
I was looking for the exact same thing, and I can confirm that SublimeCodeIntel works well. However, Sublime Text seems slightly less responsive when using SublimeCodeIntel, which is a drawback.
Another cool thing coming from a Visual Studio environment is the support for "Go to definition" in this plugin.
Another option is TernJS:
http://emmet.io/blog/sublime-tern/
I haven't yet used it, but it looks promising. Editor slowdown seems to be an issue with any code completion plugin; sounds like authors are still working out kinks in scraping and caching related files for code completion. The TernJS page addresses this issue and offers some config options for managing how it handles related files.
In Visual Studio, how do I change the default XML summary comment snippet from three lines to one line?
Currently it provides this snippet when I type ///:
/// <summary>
///
/// </summary>
I would like this shorter snippet:
///<summary></summary>
My summaries are often brief and the extra 2 line are unnecessary.
Is there a configuration setting for this or some customizable code/custom addon to fix this.
This is an older question, but I liked Jason Williams's suggestion of creating a snippet for this, so I did. Not very complicated, but copy-and-paste is even easier :)
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Single line summary</Title>
<Shortcut>summary</Shortcut>
</Header>
<Snippet>
<Code Language="csharp">
<![CDATA[/// <summary>$end$</summary>]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
You can change the shortcut by (probably obviously) changing the <Shortcut> value.
Paste that into a new file named SingleLineSummary.snippet and save it in the folder %USERPROFILE%\Documents\Visual Studio 2012\Code Snippets\Visual C#\My Code Snippets (modify to fit your version of Windows and Visual Studio).
If you're not familiar with snippets, to use this just put the cursor above a method/property/etc, start typing summary, and then hit TAB a couple of times.
Personally, I think this should be part of the VS editor itself. I know it's been requested in the past. In the meantime, the snippet idea is a good one, but the behavior is slightly different. If you want to keep the same behavior and if you are willing to purchase a 3rd party add-on, then SubMain has a product called "GhostDoc Pro" that, with a little bit of effort, will do this for you. (Note that they have a free, non-"pro" version, "GhostDoc", but I don't think it will work.)
If you want to go this route, here's how it works.
After installing GhostDoc Pro, go to your Tools menu. At the top will be a new fly-out submenu, "GhostDoc Pro".
Go to Tools -> GhostDoc Pro -> Options -> Rules
You will need to edit the T4 template for EACH type that you want this to take effect on.
Click on the rule and then hit "Edit"
At the top, modify
/// <summary>
///<# GenerateSummaryText(); #>
/// </summary>
to be just
/// <summary><# GenerateSummaryText(); #></summary>
In the method GenerateSummaryText, modify each this.WriteLine to be just this.Write
Hit OK to save, move on to the next template.
Before closing the options page, head up to "General" (from "Rules") and check the "Highlight auto-generated summary when Document This". This will cause the newly inserted auto-text to be selected off the bat so if you don't like it, you can just start typing. Of course, if you prefer to have the text just not generated at all, then you can do that, too, but you will have to modify the T4 templates a bit more. Specifically, you'll need to have GenerateSummaryText just use a single line,
this.Write(Context.ExecMacro("$(End)"));
This will have it not generate any text, but will put the cursor between the 2 <summary> tags.
Side Note:
If anyone knows of a way to get ReSharper or other add-on tools to do this, I'd be interested in seeing that solution as well--if for no other reason than just curiosity.
You can manually format the comment however you like it, as long as it remains valid xml.
The cheapest approach might be to disable the automatic comment-building action in Visual Studio (Tools > Options > Text Editor > C# > Generate XML Documentation comments for ///) and use a code snippet to insert /// <summary></summary>.
If you want the default format to be a single line, and/or help to keep the format tidy and readable, my addin Atomineer Pro Documentation may also be of interest. Among the many options is one to use a compact 1-line format for any comment that is short enough to fit on a single line. It is specifically designed to do this, so it may work better for your needs.
A final suggestion is that there are several other add-ins (Resharper, etc) that can generate simple boilerplate xml doc-comments - I believe some of these addins can be configured to use a particular text snippet. If you already have such an addin, it may be that yours can be adjusted to provide the one-line format you require, in a slightly more advanced manner than is possible with the basic Visual Studio tweak suggested above.
I was trying to do this today. I couldn't find a way to change it to happen automatically, so I figured I could do it afterward with find and replace and regex. It isn't a good answer to this question, but it doesn't appear there is a good answer and all the answers are workarounds. This is a good work around.
VS with Regex
Find: (/// <summary>)\r\n\s*///\s*(.*)\r\n\s*///\s*(</summary>)
Replace: $1$2$3
Notepad++ with regex
Find: (/// <summary>)\r\n\s*///\s*(.*)\r\n\s*///\s*(</summary>)
Replace: \1\2\3