I have posted on this before, but couldn't find a simple example. Here's one. I had some code commented out. Part if it was a comment. I used un-comment to turn the code back on for testing. And so this...
'check to see if this is a "simple" struct that has only basic types inside, not additional embedded type 5's
Turned into this...
check to see if this Is a "simple" struct that has only basic types inside, Not additional embedded type 5's
Look at the Is and Not. This isn't happening on all keywords, it appears that it's primarily Linq related terms get re-camel cased - Is, On, Where etc. And that's weird, because I don't have or use Linq in any of my projects.
This is annoying, but what is actually damaging is when this happens inside quotes. Let's say you had something like this...
'this is a "really long comment that I want to split into two lines"
Now I place my cursor in front of, say, "I" and hit return. This produces a second line with a trailing quote. Now every keyword in the entire file from that point on is re-cased, because there's an open quote confusing VS. Now my git diff is basically screwed.
Does anyone have any suggestions on what might be happening and how to turn it off?
The re-casing of keywords is a feature of "Pretty listing (reformatting) of code". This feature was less aggressive in VS versions earlier then VS2015 and did not run un-commenting a line.
To disable it go to:
Tools Menu->Options->Text Editor->Basic-> Advanced-> Editor help section
and uncheck "Pretty listing (reformatting) of code".
Related
SUMMARY:
I need the most efficient workflow to individually edit over 200 files, and have them automatically disappear from the search results as they are updated.
DETAILS:
I am in the process of adding logging throughout a legacy system, and need to update over 200 files, each with their own custom code. I need to edit them one by one, and would like for the updated files to automatically disappear from my working search results after I have completed each one. The idea is to know how many and which ones still need to be updated as I slowly work through them all.
I already had to do something similar a few months ago, but on a much smaller scale, and I used an old-school HACK to do it. I did a search and replace for my keyword, and intentionally misspelled it. I then used the misspelled keyword for my search, and corrected it when editing each file, hence automatically removing it from the list. It "works", but is obviously a TOTAL HACK.
I recently started using IntelliJ IDEA, and am not yet familiar with the more advanced features like Find in File Scopes, Search Structurally, Search Templates, etc., but I am sure there HAS to be a "correct" way to do this in IntelliJ, and I just don't know how.
I am currently using "Find in Files" to work through the list, and recently found "All Changed Files" in the Scope list, which is actually the EXACT OPPOSITE of what I need. Is there a way to show "All UNCHANGED Files"??? That would work PERFECTLY in a pinch! But really, I would rather learn the CORRECT way to do this in IntelliJ.
Thanks!
it bothers me:
why can't i "soft return" in intellij (or any IDE actually)?
is there a way i don't know of to "X + return key"?
situation: i want to copy&paste long paragraphs into a translation.json.
Afterwards, i want to format them with html tags.
So why can't i have
"translation": {
Hi!/
this is/
the text./
maybe there is a/
LINK too?/
/
Second Paragraph/
/
This is the second paragraph./
}
with /being soft wrap markers
instead of
"translation": {
Hi! this is the text. maybe there is a LINK too? Second Paragraph This is the /
second paragraph.
}
(it makes inserting the html tags a PITA)
why can't i "soft return" in intellij (or any IDE actually)?
Most likely because it is not a highly desired feature. Secondly, from a practical standpoint, the implementation would be cumbersome because most file formats an IDE uses are ultimately plain text. As such the file does not have a concept of a soft return. For an IDE to support arbitrary soft returns, it would need to maintain a data store containing the metadata of where in each and every file you've ever edited you want soft returns.
Or alternatively, the soft returns would need to be stored in the file. But the only way to do that and not "effect" the actual code in the file is via comments. Such as how an IDE uses comments to suppress warnings, create an arbitrary folded block, or turn off auto formatting. (And of course, with your example, JSON does not have comments, further complicating things.) Using comments for soft returns would, I think, result in a lot of clutter in the file. For example, for HTML, even using a one character comment of a paragraph symbol "¶" results in a lot of clutter:
"translation": {
Hi!<!--¶-->
this is<!--¶-->
the text.<!--¶-->
maybe there is a<!--¶-->
LINK too?<!--¶-->
<!--¶-->
Second Paragraph<!--¶-->
<!--¶-->
This is the second paragraph.<!--¶-->
}
You could always request a new feature to add support for something like this to IDEA, but I'm fairly sure it would unlikely gain any traction (based on 13+ years of IDEA usage and very active community membership).
I agree with #Peter's comment that more detail about the workflow you have might help. Ultimately, the Paste as plain text action he mentions is likely the solution. Or you can turn off reformatting on paste in Settings > Editor > General > Smart Keys > "Reformat on paste". See the following help page for more information: https://www.jetbrains.com/help/idea/2016.2/smart-keys.html
I often heard Snippet Expansion by an IDE, but I searched and couldn't figure out that it means. Could you explain what it is?
Snippet expansion allows you to type short sequences of characters, hit another key, and have it expanded out into a larger amount of code. This is useful for quickly writing common chunks of code.
The above image shows me writing a simple C++ program with the use of snippet expansion. I include the header, I just write inc and hit tab. To write the main function, I write main and hit tab. Similarly for the for loop and cout expression.
It means typing in a sequence of characters, e.g. "if()", pressing a keystroke, and having the IDE look up in a database for the replacement, e.g. "if(|) {\n}", and putting it in the editor in place of the sequence.
It is the feature of some ide's to expand on a certain sequence of keys which is useful to type something faster on not type it at all. Like when you start typing for and it expands to a for loop.
Personally, I use vim, and snipMate.vim enables just that. The example video is here.
I'm using several of JetBrains' products, like IntelliJ IDEA, PyCharm and PhpStorm. One issue I'm having is that when viewing a diff codelines will look different even though they are identical.
(full image)
The lines are identical, but the rendering of them are different. That's pretty annoying, as it's hard to spot where there are actual differences.
This example can be mostly solved by turning off inspections, but that turns them off for the whole project, and I will need to constantly enable and disable it.
(full image)
In this example, there's also no differences. And there are no highlighting from inspections. But still the code is rendered differently. The comment reminded my that this is because of language injections. Turning them off makes stuff look right, but I want them when I work.
How can I make my diff become more readable and the differences easier to spot without all the clutter and without disabling everything?
It's been possible for a while now to change this just for a diff-view. For instance when committing, one can press the cog and change Highlighting Level.
When I'm writing comments in my code, I often forget to add the initial space after the comment identifier.
'this is a comment
when really it is supposed to be
' this is a comment
I realize this is quite trivial, and you could simply say "just add the damn space you idiot", but I'd really like to automate this so that I just don't have to worry about it.
Can anyone point me in the right direction of an elegant way to add the comment space?
note I do realize that a catch all string replace or regex replace could screw up other things ... IE:
Dim something As String = "I'm a nerd"
would actually come out
Dim something As String = "I' m a nerd"
So the way I see this being resolved is if it's only on a line by it's self and is not followed by a second single quote... IE: '' would not trigger the replacement.
You could always get a copy of resharper and one of the rules in there is what you are describing. Once you finish with your code you can do a format on the whole file or even solution and it will globally fix that rule for you.
This would be a pretty good case for an editor extension. You can detect when a line is whitespace, apostrophe, not white space and either insert the space or put a decoration so you will learn to follow the pattern. If you've moved to 2010, consider it - they are really pretty easy to write.
I had and have similiar problems. This is a habit which you can change. Yet, sometimes your brain is just wired to make the same mistakes. For instance, no matter what I do, I always type data instead of date.
You can change your behavior. Find some method that you find helpful for changing habits. Create a "personal code review" checklist and add this item. After a few months, you will find the space comes naturally.
If this is one of the "hard-wired" brain goofs, then create a *Visual Studio" macro that visit's CodeDom. Through the CodeDom namespace it is easy to find comments and make changes as needed. Why use regular-expressions?
If you want to use regular-expressions, because you are familiar and it is easier, then create a better expression to avoid potential errors.
Refactoring VB.NET code with regular expressions at http://www.vbmigration.com/Blog/post/2008/07/Refactoring-VB%2cNET-code-with-regular-expressions.aspx should be helpful in creating better regular-expressions.