IntelliJ: Suppress quote insertion for HTML attributes - intellij-idea

In IntelliJ IDEA 11 or 12, with an HTML file open, typing
<img src=
causes automatic insertion of double quotes, resulting in
<img src=""
Since I type ahead of where I read, this usually means I end up with something like
<img src=""image.png" alt="Image"/>"
How do I prevent double-quotes from being inserted automatically after attribute names?

In Intellij IDEA 14 and 15 (see #Zook's comment for IDEA 13), the option is now
Windows:
Menu File→Settings→Editor→General→Smart Keys→Add quotes for attribute value on typing '=' and attribute completion (under XML/HTML section on the right side of the Settings dialog)
Mac:
Preferences→Editor→General→Smart Keys→Add quotes for attribute value on typing '='
I don't know if it was the same for previous versions, but what actually happens in IDEA 14 is it automatically inserts both quotes and puts the cursor inside them. That's fine, but then when you type what you expect to be your opening double-quote, the smart punctuation mechanism thinks you're closing the quotes and skips you over the automatically-inserted close quote (the same as it does in e.g. java code when you type a closing parenthesis when it has already auto-inserted one). So you wind up with the cursor after the pair of quotes, typing your attribute value. This seems consistent with the original observation.
I would actually consider this a bug in IDEA but I guess the fact that opening and closing punctuation are the same symbol in this case makes things complicated. The smart punctuation mechanism would need to know to ignore the first quote you typed, but if you actually wanted to type an empty attribute value like src="", it would need to ignore the first quote and then jump over the close quote for the second one. Fiddly, but not impossible.

I've tried it with IDEA 12 and double quotes are inserted only after you start completing src attribute and press Enter or type = to confirm the completion. It doesn't happen automatically, you invoke completion that inserts quotes.
There is no option to control it, so you will have to break your habit to insert quotes manually and use Enter instead.
It's also possible to use the template completion with:
imgTab to generate <img src="" alt=""> with the caret inside first pair quotes.
Then just enter the image file name, Tab, enter alt text.
You can always submit a feature request to disable adding quotes on attributes completion.

Just change Input Language from "US - International" to "US". Switching to just "US" fixed the problem.
Read IntelliJ thread

Related

VSCode language extension match parenthesis in quotes

I'm writing a language extension for lisp and have noticed a weird behavior. If I have something like this,
( "(" a b )
VSCode will match the closing parenthesis with the one in quotes. If I have the cursor between the a and the b and do an expand selection, it selects from the quoted open parens to the closing parens.
What controls this behavior? How do I get it to ignore the one in quotes?
I've tried messing with different settings in language-configuration.json, but nothing has worked so far. The only other thing I can think of would be the wordPattern regex, which I copied from somewhere. It's currently set to,
"wordPattern": "[^:()# \t\n\r][^:() \t\n\r]*"

How do you turn off XML code completion in IntelliJ IDEA?

In IntelliJ IDEA if you open an XML document and start entering XML
<body name=
Then the software immediately and undesirably adds untyped quote characters
<body name=""
Without realizing there is extra input I continue to type a quote character followed by the value of the property followed by another quote character
<body name=""value""
and that's a syntax error.
The preferences has a whole section for Auto Completion and I unchecked every box. That didn't change anything, the XML editor still does it. How is this feature controlled?
Disable Add quote for attribute... under Preferences | Editor | General | Smart Keys | HTML/CSS

How do I stop SQL splitting string literals when I press Enter in DataGrip or IntelliJ Database Editor?

When my cursor is after an open quote in a SQL statement in an IntelliJ database console and I press Enter, it closes the quote on the current line and adds a concatenation symbol with an open quote on the newline.
I disabled formatting the SQL code style settings but that didn't fix it for me.
UPDATE blah SET blah2 = 'something<pressed enter>' ||
'<argh!>...';
Is there a way to disable this autoformatting?
This request was addressed in 2017.1 version, as a result, Insert string concatenation on Enter setting was added specifically for SQL:
This can be archived since IntelliJ 13. You simply need to wrap your code with
// #formatter:off
your code goes here
// #formatter:on
Since IntelliJ Idea 15-16(pardon if i'm wrong), you can also make permanent set up by Preferences > Editor > Code Style option
Hope it helps

How do I auto indent a long method after typing in the finish semicolon in XCode5?

I have a long method, after I type it in, it looks like this:
[someObj action1:param1 action2:param2 action3:param3 action4:param4];
But I want it to become like this... :
[someObj action1:param1
action2:param2
action3:param3
action4:param4];
...automatically after I type in the last semicolon.
I just saw a video that did this, so how do I do that?
(It is a paid video so can't give link here)
For the question text:
[someObj action1:param1 action2:param2 action3:param3 action4:param4];
if you have already entered that on one line just select the space between parameters and return
That will tend to alligh the colon ":" characters on multiple lines.
To auto-indent already entered code select the text that you would like auto-indented and then control i and that selection will be indented to Xcode rules.
I use that all the time.
If you just want to move a selected block of code to the left command [, to the right command ]
Have a look at https://github.com/travisjeffery/ClangFormat-Xcode.
It will reformat your code to adhere to style rules, like Chromium's for example, where the line length is 80 chars max.
In this case, the method will be wrapped as you mentioned if it's more than 80 chars.
You can either reformat on a particular key combination, or on each save.

Intellij - Reformat Code - Insert whitespace between // and the comment-text?

I am working with another human being on project from that the professor expects to have uniform code-style. We have written large separate junks of code on our own, in which one has written single line comments without a white-space between the single-line-comment-token and the other one has inserted a white-space. We are working with IntelliJ and have failed to find an option to enable the Reformat Code function, to insert a white-space.
TLDR:
Can you tell us how to convert comments from that to this in IntelliJ?
// This is a load bearing comment - don't dare to remove it
//This is a load bearing comment - don't dare to remove it!
You can do a global search and replace (ctrl-shift-r on windows with default keyboard layout, or Replace in Path under the Edit/Find menu).
Check the regular expression option and enter //(\S.*) as the text to find and // $1 as the replacement. Check the whole project option, and clear any file masks. You can single step through the replacements, or simply hit the All Files option.