In Vim can I automatically soft wrap comments with alignment at the first character - auto-indent

I'm currently using vim to take notes and the way I'll usually do that is as follows:
- First line of info
- Sub line of info
- More sub information
- Second point
- Third point, etc
However, when writing long lines the output will look as follows:
- First line of info that is really long
goes down to here
- Subpoint line of info that is short
- Subpoint line that is really long goes to
here and continues
- Subpoint line that is short again
- Second point that is really long goes to
here, etc, etc
What I'd really like is if it looked like this:
- First line of info that is really long
goes down to here
- Subpoint line of info that is short
- Subpoint line that is really long goes to
here and continues
- Subpoint line that is short again
- Second point that is really long goes to
here, etc, etc
This would make it easier to see when each new point or subpoint was started because of the "-" sticks out more.
If possible I'd like:
automatic inserting of the leading character (doesn't have to be a dash) on enter
automatic inserting of the leading character (doesn't have to be a dash) on o and O
automatic soft wrapping of the text to the correct indentation level
automatic soft wrapping of the text to the first character after the leading character
I've been able to achieve the first three using the following:
set formatoptions=ro
set comments=b:-
set breakindent
set autoindent
However, when trying to get the soft wrapping at the first character after the "-" I am having trouble.
I've tried using set formatoptions+=n with an accompanying formatlistpat=^\s*-\s*. However, then it is not automatic and I need to use gq which seems like it makes a second line instead of just soft wrapping. If using set formatoptions+=wan I can get it sometimes automatically wrapping but it is once again a hard line break, not a soft wrapping.
If anyone could help that would be greatly appreciated!

So I've finally figured it out. The answer was breakindentopt :help breakindentopt
Specifically set breakindentopt=shift:2
This causes the line that is wrapped due to breakindent to shift two spaces two the right which lines everything up the way I wanted.
The full settings which achieve what I was going for are:
set formatoptions=ro
set comments=b:-
set breakindent
set autoindent
set breakindentopt=shift:2

Related

How to shorten the first line in the Intellij console?

I want my first line at the top of the console to look like this:
, but mine looks like this, and it's long:
How can I shorten it to like the first picture?
I'm watching Java tutorials on youtube and their first lines ("C:\programs Files\Java\jdk\whatever"...) are always so short and pretty with 3 cute dots in the end, but mine is long and annoying.
You can define the lines which should be folded:
Right click on that line in the console
Choose "Fold Lines Like This"
Click OK
You can also define special keywords/phrases in this menu, where lines, which contains the phrase will be folded with ellipsis (...) at the end.
See the ConsoleViewImpl.java file in the source code of IntelliJ IDEA
This line (execution command) will be automatically hidden in case the string length is more than 1000 symbols.
So, once you add something to the execution command (for example by adding libraries), the execution command is folded automatically.

Intellij is incorrectly formatting my `.yml` file, I cannot see any errors in my style settings. how can I fix it?

Intellij keeps formatting my spotbugs.yml file incorrectly, and so breaking the github action.
I cannot figure out why it's doing this:
It was working fine last week, I haven't made any changes to the formatting config, but now, every time I change focus from the file Intellij auto-formats like this, then saves it. How can I fix it?
The thing I don't get is what it's formatting to appears to be invalid yaml, right?
YAML has a syntax that makes it incompatible with indentation that is not 2 spaces. With 4 spaces, you have:
droggel:
jug:
- sequence item: with indentation
this line: isn't aligned to four spaces
nor are further indented lines:
if you indent relative four spaces
spam:
- same: problem
without: indenting the sequence item
This makes it hard for code formatters to get it right. Proper alignment would mean:
droggel:
jug:
- three spaces after the sequence item indicator.
that's horrible, nobody does that.
spam:
- alternatively this.
nobody does this either and it breaks
- - with nested sequences
I assume some bug in IntelliJ causes the formatter to be confused because of this. Generally it would be better to just use 2 space indentation which seems far more natural due to the problems described above. That should avoid confusing the formatter.

OpenSCAD parser error in the *middle* of a comment when last line accidentally uncommented?

I have the following segment of comment in my code file (the last line is intentionally missing the slash characters - that the error):
// * Cube Back Text from Méi guī
// 一颗 心 怕 摔倒 打破
//"yī kē xīn pà shuāi dǎo dǎ pò"
// "It's the heart afraid of breaking"
// 不敢 起舞 欢 歌
// "bù gǎn qǐwǔ huāngē"
// "that never learns to dance."
不敢起舞欢歌 (dance)
But the red error dot appears on the second character of the second line (second slash of the line "// * Cube Back Text from Méi guī".
Stranger, if I remove various quotes in the comment, the character that is hilited changes.
I assume this has something to do with a recursive structure somewhere in the parser that is continuing to parse the quotes inside the comment itself and ultimately figures out where to signal the error.
I suppose this is a bug ("semi-bug") that I should post to the GitHub list - to completely ignore anything past the second slash on a commented line, or some other change so that the error tag shows up on the line where the error actually is?
As it is, I futzed around about 10 minutes wondering if OpenSCAD just didn't like files longer than 575 lines.
I get the same problem when I try your example or modify it slightly but it worked perfectly when I replaced everything with random Latin characters so I think the bug has a lot to do with the Chinese ideographs you used.
In any case, I only copied the small sample you gave so it probably have nothing to do with the length of the file.

BigQuery Line numbering

Maybe i'm missing something, but does anyone know how the debugging line numbering works in BigQuery?
I get an error like this:
Failed to save view. 2.196 - 2.226: Ambiguous column name eventcode.
and I'm not sure what the address 2.196-2.226 means. Specifically, what does the decimal signify? The second line of my query is very short (just SELECT *), so I don't think the numbers after the decimal indicate a character range?
Anyway -- I can't find any info for it in the docs, so any help here would be great
Line counting is most like shifted by 1 so it is actually line number #1 (not #2)
196 - 226 points to char range on that line with piece of code that introduces ambiquity - just the second piece (that has already existing aliac or column name for it)
Somehow for some first lines line numbering is incremented by 1 - it can be a bug on BQ UI side.
Btw, I noticed same strange behaviour in CodeMirror BQ UI is using, so it can be CodeMirror's bug too

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.