IntelliJ IDEA removing the character after on reformatting code - intellij-idea

IntelliJ removes the character after while reformatting. For example if I misspelled "Father" as "Fathr" and want to add an "e" afterwards, the editor removes the "r" on adding "e". I'm new to Kotlin and would really appreciate some help.

I am afraid this is just a simple Insert key that switches the input mode between insert (a thin cursor) and replace (a fat, character sized cursor).

Related

IntelliJ make whitespace+newline same word

When deleting words (ctrl+backspace or ctrl+delete) in IntelliJ it treats whitespace as a word until it hits a newline character. I want to treat every sequence of space/tab and newline[sequences] as one word.
Essentially this is the reverse problem of this question in IntelliJ.
Sadly i did not find any setting to do that so far.
There exists a "Hungry Backspace" action.
Yet there exists no "Hungry Delete" out of the box.
And it does not work for non-whitespace words.

VBA replace certain carriage

All.
I am used to programming VBA in Excel, but am new to the structures in Word.
I am working through a library of text files to update them. Many of them are either OCR documents, or were manually entered.
Each has a recurring pattern, the most common of which is unnecessary carriage returns.
For example, I am looking at several text files where there is a double return after each line. A search and replace of all double carriage returns removes all paragraph distinctions.
However, each line is approximately 30 characters long, and if I manually perform the following logic, it gives me a functional document.
If there is a double carriage return after 30+ characters, I replace them with a space.
If there were less than 30 characters prior to the double return, I replace them with a single return.
Can anyone help me with some rudimentary code that would help me get started on that? I could then modify it for each "pattern" of text documents I have.
e.g.
In this case, there are more than
thirty characters per line. And I
will keep going to illustrate this
example.
This would be a new paragraph, and
would be separated by another of
the single returns.
I want code that would return:
In this case, there are more than thirty character returns. And I will keep going to illustrate this example.
This would be a new paragraph, and would be separated by another of the single returns.
Let me know if anyone can throw something out that I can play with!
You can do this without code (which RegEx requires), simply using Word's own wildcard Find/Replace tools, where:
Find = ([!^13]{30,})[^13]{1,}
Replace = \1^32
and, to clean up the residual multi-paragraph breaks:
Find = [^13]{2,}
Replace = ^p
You could, of course, record the above as a macro...
Here is a RegEx that might work for you:
(\n\n)(?<!\.(\n\n))
The substitution is just a plain space, you can try it out (and modify / tweak it) here: https://regex101.com/r/zG9GPw/4
This 'pattern' tells the RegEx engine to look for the newline character \n which occurs x2 like this \n\n (worth noting this is from your question and might be different in your files, e.g. could be \r\n) and it assumes that a valid line break will be proceeded by a full stop: \..
In RegEx the full stop symbol is a single character wild card so it needs to be escaped with the '\' (n and r are normal characters, escaping them tells the RegEx engine they represent newline and return characters).
So... the expression is looking for a group of x2 newline characters but then uses a negative look-behind to exclude any matches where the previous character was a full stop.
Anyway, it's all explained on the site:
Here is how you could do a RegEx find and replace using NotePad++ (I'm not sure if it comes with RegEx or if a plugin is needed, either way it is easy). But you can set a location, filters (to target specific file types), and other options (such as search in sub-directories).
Other than that, as #MacroPod pointed out you could also do this with MS Word, document by document, not using any code :)

jEdit in hard word-wrap mode: insert comment character automatically?

Probably quite a niche question, but I believe in the power of a big community: Is it possible to set up jEdit in way, that it automatically inserts a comment character (//, #, ... depending on the edit mode) at the beginning of a new line, if the line before the wrap was a comment?
Sample:
# This is a comment spanning multiple lines. If I continue to type here, it
# wraps around automatically, but I have to manually add a `#` to each line.
If I continue to type after the . the third line should start with the # automatically. I searched in the plugin repository but could not find anything related.
Background: jEdit has the concepct of soft and hard wrap. While soft wrap only breaks lines visually at a character limit, it does not insert line breaks in the file. Hard wrap on the other hand inserts \n into the file at the desired character count.
This is not exactly what you want: I use the macros Enter_with_Prefix.bsh to automatically insert the prefix (e.g., #, //) at the beginning of the new line.
Description copied from Enter_with_Prefix.bsh:
Enter_with_Prefix.bsh - a Beanshell macro for jEdit
that starts a new line continuing any recognized
sequence that started the previous. For example,
if the previous line beings with "1." the next will
be prefixed with "2.". It supports alpha lists (a., b., etc...),
bullet lists (+, =, *, etc..), comments, Javadocs,
Java import statements, e-mail replies (>, |, :),
and is easy to extend with new sequence types. Suggested
shortcut for this macro is S+ENTER (SHIFT+ENTER).

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.

IntelliJ: Suppress quote insertion for HTML attributes

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