How make clang-format indent using tabs instead of spaces? - clang-format

Testing with the following
clang-format -style="{BasedOnStyle: Google, UseTab: Always}" -i /path/to/file.ino
Results in spaces instead of tabs

Internally, clang-format only works with spaces, its not until the final step it replaces spaces with tabs and then it will only replace them in groups of TabWidth. Since the Google style has IndentWidth: 2 and TabWidth: 4 it wont replace them with tabs unless there are two indents on the same line.
You'll have to sync up IndentWidth and TabWidth for it to work on every line:
IndentWidth: 4
TabWidth: 4

You can use the UseTab option, for example:
UseTab: Always
IndentWidth: 8
TabWidth: 8

Related

Ckeditor 5 removing line-breaks from copying data

I use classic default ckeditor 5 build.
The problem is if I copy from notepad text like:
1
2
3
In editor I give result:
1 2 3
If I copy next text:
1
2
3
In editor I give:
1
2
3
Why ckeditor removing one line-break per line ?
You encountered something that can be considered a bug or a missing feature.
Single \n line characters, which are converted to <br> on paste are lost due the fact that CKEditor 5 doesn't support soft-line breaks yet.
On the other hand, not everyone need to load the soft-line break feature so, even if we'll introduce it, the problem will occur for these users. Hance, perhaps the plain text to HTML conversion should work differently. Or be configurable.
More info https://github.com/ckeditor/ckeditor5/issues/766

Can you set clang-format's line length?

clang-format is breaking up my lines at 80 columns. Is there a way to make stop breaking lines? The documentation doesn't seem to address this.
The configuration option responsible for it is called ColumnLimit. You can remove the column limit by setting it to 0.
ColumnLimit: 0
Find ColumnLimit (under "Configurable Format Style Options" heading) on that page and you'll find the following statement:
ColumnLimit (unsigned)
The column limit.
A column limit of 0 means that there is no column limit. In this case,
clang-format will respect the input’s line breaking decisions within
statements unless they contradict other rules.
Source: Clang-Format Docs (v4.0.0, latest). Italics added for emphasis.
So, just like the docs say, set...
ColumnLimit: 0
... and you should be set.
I had the same issue too - I am using the C++ extension in VSCode and setting ColumnLimit: 0 still wrapped at 80. I worked around this by setting ColumnLimit to a large number; I set ColumnLimit: 200 and it works great.

select noncontinuous lines in Ed

if 3,5p prints lines 3, 4, and 5, how would one print, say, lines 4 AND 7, but not 5 and 6?
Have tried:
3 5 p prints line 8
3p5p breaks as well
ed doesn't generally let you manipulate disjoint lines like this so you'd normally just do
4p
this is line 4
7p
this is line 7
However, ed does allow for a command-list within the context of a g// command, so if you really do need all the output in one response, you can hack it with
1g/^/4p\
7p
this is line 4
this is line 7
It's ugly, it's a hack, and it's inconvenient to type. But if you really do need all the output in one pass, this will do it.

Multiple-line collapse in Notepad++

I want to use notepad++ to do multiple-line collapse. What I mean is that I am looking for a simple operation to turn
1
2
3
4
into
1 2
3 4
How about:
Ctrl+H
Find what: (.+)\R(.+)(\R)
replace with: $1 $2$3
Replace all
Where \R stands for any kind of linebreak.
This will replace a linebreak between 2 lines by these 2 lines separated by a space.

Joe's own editor - how to change the tab size

I'm having trouble changing the tab size in Joe.
I have copied joerc to $HOME and have edited the -tab line to -tab 4 but this hasn't changed the option in Joe. Also the number 4 is green instead of blue when I edit joerc so I think its reading it wrong.
The real solution is:
Create a file $HOME/.joerc (NOT .joe as at least the Debian joerc suggests!)
FIRST LINE must be :include /etc/joe/joerc
Then, a line containing just a * and a newline character
Then, -tab 4 and -istep 4, each on a single line.
Add a blank line at the end.
You may also add further options with other masks.
I've wasted about 20 mins trying to set tab size too. Here is the solution:
I. Open:
/etc/joe/joerc
II. Find row containing -tab nnn and change it to:
-tab 4
(I assume that you want to change tab size to 4. If you want different value, please replace all the 4s with your value)
III. Find -istep nnn and change it to:
-istep 4
IV. Save & exit
This will set tab size 4 for files WITHOUT extension. If you want to change tab size for files with common extensions like *.java:
I. open /etc/joe/ftyperc
II. Find your extension, for example *.java. Initially it looks like:
JAVA
*.java
-autoindent
-syntax java
-smarthome
-smartbacks
-purify
-cpara >#!;*/%
III. You have to comment (insert tab before it) -autoindent and add -istep 4 bellow -cpara. It should look like:
JAVA
*.java
-autoindent
-syntax java
-smarthome
-smartbacks
-purify
-cpara >#!;*/%
-istep 4
In case anyone else runs into this, I am running an ancient version of joe on AIX and after some painful trial and error it turned out that -smartbacks was the problem for me. I commented that line out and tabs work, put it back and they go back to 2. Probably fixed in a later version, but hopefully this helps someone else with the same problem.
JAVA
*.java
-spaces
-tab 4
-istep 4
-indentc 32
-autoindent
-syntax java
-smarthome
-smartbacks
-purify
Each time the tab key is pressed (using joe 4.6) it inserts 4 spaces after having followed those steps:
Execute sudo joe /etc/joe/joerc
Find the row containing -tab nnn Tab width, change it to -tab 4 Tab width and make sure that there is no whitespace at its left side.
A few lines down, find the row containing -spaces TAB inserts spaces instead of tabs and make sure that there is no whitespace at its left side.
Save and exit
This works here for files without extension, for .cpp files, for .java files, for .c files, for .txt files, etc.

Resources