-Edited-
First of all - thanks for the answers.
settings->quote indeed looks like
the right direction.
That being said.. I understand that there is no reality in which I get to keep BOTH my single, AND double quotes,
and just turn off ONLY the quote thing checker/fixer style.
-Original-
My VSCode changes the ['] char to ["] automatically every time it saves.
I have the autosave feature (out of focus, etc.) turned on.
So.. at this point, writing NodeJS is becoming insufferable.
Tried looking through my extensions, settings, and even deleted all the unused and old ones.
Nothing.
I'm down to these 5, and can't seem to find the answer (Of course, "Prettier" was the first thing I checked. so if it's there, I either didn't get it, or missed it.)
In the settings of VS Code, just search for javascript.preferences.quoteStyle to get the exact result. But this is the setting you need to change in order to tell Prettier that you want single quotes instead of double quotes.
You can tell prettier that you prefer single quotes by having a config file (for example, a .prettierrc at the root of your project that has singleQuote set to true. The default is false.
{
"singleQuote": true
}
Related
If I have a string like this: 'don\'t fix me' prettier will change single quotes to douples: "don't fix me". This is extremely frustrating since our .eslint rules will give errors and I have to manually fix every single string back to 'don\'t fix me' format before I can push to our repository. I can't change prettier or eslint rules as they are managed by seniors. Is there any way to fix this behaviour without messing with .eslintrc or .prettierrc?
I am using VS Code, but haven't found extension to help me here.
I opened a Modelica library in Dymola, changed one line, closed Dymola and clicked "Save all", now TortoiseSVN is showing several hundred changed files instead of just one file with the one line changed I intended to do. All these changes are either whitespace, or line breaks, introduced by Dymola it seems.
Of course I can now be careful to only commit the file I have changed (and revert the rest), but that makes committing more time-consuming and error-prone than it needs to be. Or I can just commit it all, but that makes it hard for my colleagues to review the change. Also, it feels like it is not deterministic, so a later commit might just revert parts back. I sometimes even revert all changes, then use a text editor to change just the one line. All this makes version control unnecessarily complicated.
When I look at the commits and diffs for e.g. the Modelica Standard library:
https://github.com/modelica/ModelicaStandardLibrary/commits/master
The diffs are nice and small and readable usually. Is there a trick to avoid the whitespace issue?
How I can I turn off all autoformatting by Dymola? Is there a technical reason to do it in the first place?
You can reduce (but not entirely prevent) this behavior as follows:
Increase the maximum line length, e.g. to 130
In the GUI: Options > Text Editor > Max line length
From the command line: Advanced.MaxLineLength=130
Let Dymola format your whole library one time
Open the text view of the top-level package
Mark everything with Ctrl+A
Auto-format with Ctrl+Shift+L or Right-Click > Auto-Format
Save everything with Ctrl+Shift+S
Now go through the changes. Most will be useful, but sometimes spaces are removed, which you usually like to keep (especially before import and extends statements. They are sometimes moved to the very left)
Commit the changes
From now on try to save individual models only, not packages
(When packages are saved, Dymola sometimes reformats the nested classes)
There are some things you can do to make pretty git commits for Modelica code:
Use a text editor instead of a graphical editor. You have absolute control of what you change.
Use a graphical editor that does not change whitespace. I'm not sure of other alternatives, but OpenModelica/OMEdit will preserve existing indentation as much as possible (it can also be used to minimize diffs from changes in other tools, but it works less and less well the more changes there are).
Use a formatter as a pre-commit hook (indenting all files according to some settings in the formatter; but then you can't manually change whitespace).
Hope someone on stackoverflow has more alternatives than this.
I mess with software written by completely unrelated groups of people, and it all uses completely different indentation standards. I'm okay with having to set the indentation width, but there's nothing more annoying than opening up a file with tabs, making some changes, and finding that my changes used spaces for indentation instead.
All the software I write uses four-space indentation. Then I go to make a Quake 3 mod and the entire codebase uses tabs. When I make changes I have to be incredibly careful to set my indentation settings first or I'm going to have to manually rewrite the indentation before committing, every single time.
I went through the settings and couldn't find anything. The tabs-and-spaces mode literally doesn't do anything special and just sets it to tabs mode instead (after a reset). I went through google and all I found was this extremely unhelpful mailing list message. Detecting consistent indentation isn't that difficult, other text editors manage it fine, it doesn't have to be perfect, it just has to work most of the time.
If Kate has a setting for this, where is it, and if it doesn't, when is it going to get such a setting? If I can't make Kate do this I'm going to have to switch off of it. I already went through Notepad++ and Geany, but they both have serious problems with doing regexes on extremely large files (say, tens of megabytes of text) or with rendering monospace non-european text.
Unfortunately, kate does not support this right now. There is a bug report for this from 2005, but noone implemented that yet (yes, 13 years ago).
What Kate does support though are Kate modeline (also called document variables). For instance, you can write in your text document e.g.:
// kate: replace-tabs on; indent-width 4;
And then the document containing this comment will automatically use 4 spaces and use spaces to indent.
Instead of writing these kind of comments into files, you can also write this into files called .kateconfig. You can find more information about .kateconfig files and modelines in this article.
When I add a Class into a Typescript Application, WebStorms Smart Code Completion finds the reference and creates an import reference automatically.
This is great, but the format is different to the TSLinter, I was wondering if there is a way of altering the generated code so that it will use single quotes instead of double quotes
Thank you #LazyOne, I altered this setting and now single quotes are used. It may be a little bit to much as it will effect all TypeScript string insertions, but I will try this for now.
I'm wondering whats the point of this, first I think it's not a good idea to use space for indentation (somehow Android Studio think it does), second even if I tell it to use tabs it always starts with two tabs on new line, instead of one, turning this:
getSupportFragmentManager().beginTransaction().commit();
into this:
getSupportFragmentManager()
.beginTransaction()
.commit();
Why the two tabs? I know you can set it as "Continuation Indent" to one tab or whatever you want, but cant really understand this, is there anyone who uses two tabs instead of one? What is the thought behind it? Why two tabs by default?
I can only assume it's so that the continuation method calls are somewhat closer to the first method in the chain, for readability. Variable/field/method names are generally more than 8 characters long; they are rarely around 4 characters. When writing using a builder pattern, you generally put the first method on the first line and then subsequent methods should be roughly underneath.
E.g. this:
foobarbaz.builder()
.foo()
.bar()
.baz()
.build();
Rather than this:
foobarbaz.builder()
.foo()
.bar()
.baz()
.build();
In this case, it's more obvious that the methods are stacked on top of each other in the first case.
Obviously the readability depends on the length of the method/variable name on the first line. But I think JetBrains just tried to guess the typical length and set the continuation indent accordingly.