How to prevent clang-format from indenting comments that start at column 0? - clang-format

I want clang-format to not indent or change at all any comments that start at the beginning of a line.
The reason is that in Eclipse I can comment and uncomment a line by typing ctrl+/ but if once commented and then indented by clang-format and then uncommented the final indentation is wrong.
Any ideas on how to do it?

Related

How to remove the last line in xterm.js

I'm trying to remove the last line of a xtermjs terminal. In the docs I have only found the clear and reset methods, but I just want to remove the last line.
I solved this based on the answers of this question
\33[2K erases the entire line your cursor is currently on
\033[A moves your cursor up one line, but in the same column i.e. not
to the start of the line
\r brings your cursor to the beginning of the line (r is for rewind)
but does not erase anything
I ended up using this to erase the last line:
terminal.write('\x1b[2K\r')
\x1b is the hexadecimal of \033, because I was getting this error when using the octal version.
Octal literal in strict mode

Force clang-format to respect doxygen block comments

I use long block C-style Doxygen comments in my C/C++ code. This is style #4 listed on http://www.doxygen.nl/manual/docblocks.html and looks like this (running out to 80 characters)...
/**************************************************************************//**
* \file
* \date 2017-01-02
* \author Alex Hogen
******************************************************************************/
If I run clang-format on this, it inserts a single space between the two forward slashes, so it looks all goofy like this....
/**************************************************************************/ /**
* \file
* \date 2017-01-02
* \author Alex Hogen
******************************************************************************/
I have SpacesBeforeTrailingComments set to 2, so that can't be the problem.
Tried CommentPragmas regex \/\*+\/\/\*+.
Tried CommentPragmas regex /\*(.+\n.+)+\*/
I've tried setting ReflowComments to false
... but none of those things have worked.
I understand there are two comments in this block, but I can't find any clang-format parameter addressing block comments on the same line. How can I stop clang-format from inserting this space?
And I don't want to solve this by disabling clang-format for every Doxygen comment block. That seems ridiculous.
Any good suggestions? :-)
In your .clang-format file:
CommentPragmas: '^\\.+'
This will make it not format comment line that starts with a backslash followed by a word. This works even though there is an asterisk before the doxygen comment because clang-format automatically ignores asterisks and whitespace at the beginning of every comment line.

Clang Format - How to remove space between [ and ::namespace?

Clang-format inserts pretty annoying whitespace in the example below:
blahblah[ ::namespace]
I want it to be formatted like this:
blahblah[::namespace]
Is there a way to do this?
Edit:
I've tried setting SpacesInSquareBrackets: false, but it doesn't help.
Starting with clang-format 3.9.0, that space is no longer inserted. In fact, now you can't get that space back even with SpacesInSquareBrackets: true.

How to take off line numbers in Vi?

For displaying line numbers in a file, I use command:
set numbers
What is the command to clear line numbers from the file?
If you are talking about show line number command in vi/vim
you could use
set nu
in commandline mode to turn on and
set nonu
will turn off the line number display or
set nu!
to toggle off display of line numbers
Display line numbers:
:set nu
Stop showing the line numbers:
:set nonu
Its short for :set nonumber
ps. These commands are to be run in normal mode.
To turn off line numbering, again follow the preceding instructions, except this time enter the following line at the : prompt:
set nonumber
For turning off line numbers, any of these commands will work:
:set nu!
:set nonu
:set number!
:set nonumber
Easily Display Line number:
set number flag (to show line number type)
:set nu or :set number
to unset the number flag (hide the line number type)
:set nu!
If you need number every time you start vi/vim, append following line to your ~/.vimrc file:
set number
Open a file at particular location/line number
$ vi +linenumber file.rb
$ vi +300 initlib.rb
set nonumber
set norelativenumber
If you are using some vim bundles.
From the Document "Mastering the VI editor":
number (nu)
Displays lines with line numbers on the left side.
set number
set nonumber
DO work inside .vimrc and make sure you DO NOT precede commands in .vimrc with :
write command in terminal:
vi ~/.vimrc
for set the number:
write set number
for remove number:
write set nonumber

Latex Multiple Linebreaks

I use LaTeX to type up programming homeworks for classes. I need to do this:
my line of text blah blah blah
new line of text with blank line between
I know I can use double slash to break lines \\, but LaTeX will only take the first line break (complains about more) and starts a new line, it produces this :
my line of text blah blah blah
new line of text with blank line between
How can I get that extra line break in there so I can have space between my lines of text?
Line break accepts an optional argument in brackets, a vertical length:
line 1
\\[4in]
line 2
To make this more scalable with respect to font size, you can use other lengths, such as \\[3\baselineskip], or \\[3ex].
Do you want more space between paragraphs? Then you can change the parameter \parskip.
For example, try
\setlength{\parskip}{10pt plus 1pt minus 1pt}
This means that the space between paragraphs is usually 10pt, but can grow or shrink by up to 1pt. This means you give LaTeX the ability to change it up to one 1pt in order to achieve a better page layout. You can remove the plus and minus parts to make it always your specified length.
If you are trying to display source code, try the listings package or use verbatim. If you are trying to typeset pseudocode, try the algorithm package.
Insert some vertical space
blah blah blah \\
\vspace{1cm}
to scale to the font, use ex (the height of a lowercase "x") as the unit, and there are various predefined lengths related to the line spacing available, you might be particularly interested in baselineskip.
You can use the setspace package which gives you spacing environments, e.g.:
\documentclass{article}
\usepackage{setspace}
\begin{document}
\doublespace
my line of text blah blah blah
new line of text with blank line between
\end{document}
Or use a verbatim environment to control the layout of your code precisely.
For programs you are really better off with a verbatim or alltt environment, but if you want a blank line that LaTeX will not bitch about, try
my line of text blah blah blah\\
\mbox{ }\\ %% space followed by newline
new line of text with blank line between
While verbatim might be the best choice, you can also try the commands \smallskip , \medskip or guess what, \bigskip .
Quoting from this page:
These commands can only be used after
a paragraph break (which is made by
one completely blank line or by the
command \par). These commands output
flexible or rubber space,
approximately 3pt, 6pt, and 12pt high
respectively, but these commands will
automatically compress or expand a
bit, depending on the demands of the
rest of the page
I find that when I include a blank line in my source after the \\ then I also get a blank line in my output. Example:
It's time to recognize the income tax as another horrible policy mistake like banning beer, and to return to the tax policies that were correct in the Constitution in the first place. Our future depends on it.
\\
Wherefore the 16th Amendment must forthwith be repealed.
However you are correct that LaTeX only lets you do this once. For a more general solution allowing you to make as many blank lines as you want, use \null to make empty paragraphs. Example:
It's time to recognize the income tax as another horrible policy mistake like banning beer, and to return to the tax policies that were correct in the Constitution in the first place. Our future depends on it.
\null
\null
\null
Wherefore the 16th Amendment must forthwith be repealed.
\\\\
This works on pdfLatex. It creates 2 new lines for you.
Maybe try inserting lines with only a space?
\ \\
\ \\
This just worked for me:
I was trying to leave a space in the Apple Pages new LaTeX input area. I typed the following and it left a clean line.
\mbox{\phantom{0}}\\

Resources