Removing trailing spaces with clang-format - clang-format

As the title says, I'm trying to get clang-format to remove the trailing white spaces of my files, but I fail to find the relevant option name.
Could anyone point me to the obvious?

clang-format does remove trailing whitespaces automatically.
You can test this by e.g. clang-format -style=Google file.cpp -i.
It is also useful to know most modern editors do have built-in options to do this and even more for you on save. Here are a few:
In Sublime text settings set trim_trailing_white_space_on_save to true.
In VScode set files.trimTrailingWhitespace to true.
In Vim you need a vimrc file as described here.
etc.

Related

How can I get clang-format to change only indent width?

I have a large code base that I want to standardise the indent width for.
How can I do this with clang-format without making other changes?
Passing -style='{IndentWidth: 2}' to clang-format
makes other changes to the source files as -dump-config implies.
clang-format doesn't support that at all. You might get somewhat close to that by setting "ColumnLimit: 0" which will make clang-format accept the existing line breaks to a certain extent.

Notepad++: block comment not working

I am running Notepad++ 5.8.5 on Windows 7, editing Perl programs.
I would like to comment out a block of text lines (and later, perhaps, uncomment it).
None of the following works:
CTRL+K, CTRL+Q, CTRL+shift+K, CTRL+shift+Q,
selecting the block of lines and going to the menu: edit-> Comment/Uncomment -> Block Comment
none of the above has any effect.
What to do?
Is NP++ interpreting your file as Perl or plain text?
If NP++ is treating your file as plain text, then language specific things like that won't work.
You may want to double-check that as described here.
Why not try updating to a newer version? That's horribly out of date (a year old).
Define your own language to match to the file extension, in your case it is: txt
and then define any comment style you want. Then close and open NP++ again. Enjoy!
Path: Language--->Define your Language --> Comments & Number tab
Hank Wei

VIM folding for ERB files?

Vim noob here. I have code folding working in most places, via indent mode, but for some reason I cannot get Vim to fold .html.erb files in ruby... even with indents.
Here's the relevant region of my vimrc. Is there something else I need to do to make Vim aware of the erb files? Is it possible to customize my folding per file type?
I'm running all the Janus plugins, so have rails.vim, etc. all installed.
let ruby_fold=1
set foldmethod=indent
set foldcolumn=0
set foldlevel=99
nnoremap <space> za<cr>
It's a difficult question, because there's probably something in your vim configuration that inhibits folding and I, for example, can't reproduce it. But I can suggest a few things you could try.
First of all, check what the values of those settings are in the actual buffer. Meaning, open up an erb file and check if the settings are correct. In order to do that, you can type, for example, set foldmethod, which will echo the current value of foldmethod to the screen. If one of the settings doesn't match the ones in your .vimrc, then that might be the problem.
Also, see if the file really does have the "eruby" filetype. If it's not displayed in your statusline, you could check that with set filetype.
Most importantly, one way of customizing settings per filetype is by creating a file with the filetype's name inside the ~/.vim/ftplugin directory. In your case, you can create the file ~/.vim/ftplugin/eruby.vim and put any filetype-specific settings in it. Setting them with setlocal instead of set will keep them local to the file. If it turns out the settings for erb are off, you can "fix" them by putting the values you want there.

Not working tab configuration in VIM for Javascript files in Rails project

I am trying to set some tab indent configurations in Vim. Unfortunately I can't get it working.
In my last line I use
u FileType javascript set tabstop=4
in the hope of having the tab width set to 4.
But when I open a .js file and press tab it inserts only 2 spaces. I tried to comment out the other whitespace stuff without success.
Here is also my full vimrc: https://gist.github.com/919909
How do I set the tabs and so on for Javascript files, and why does the above not work?
Update
The problem seems to be somewhere else as when editing new Javascript files it works as expected. It only seems to behave differently on the Javascript files in my Rails project.
How could that be? I have a Rails.vim plugin installed, could that be the cause?
'tabstop' is the number of spaces a tab character in the file counts for. The number of spaces of an indentation level is set with the 'shitfwidth' option, and the number of spaces that a tab counts for when doing edit operations is set with 'softtabstop'. It's a little complicated, but if you set both 'shitfwidth' and 'softtabstop' to the same value, you'll probably get what you want. You can keep 'tabstop' at the default value.
If you are one of those that like spaces all the time and not tabs, you these settings will probably suit you.
The Rails plugin is probably setting some of these leading to the different behavior you're experiencing.
Ok, the root of the problem seems to be in Rails.vim (see https://github.com/tpope/vim-rails/pull/78)
But there is also this easy solution:
autocmd User Rails/**/*.js set tabstop=4

How do I get rid of the "Release 1" in the Page Header of the Sphinx Latex Output?

I'm using the "manual" document class of Sphinx and I'm quite happy with how the Latex Output looks like, except for the page header. It contains the title of my paper, as well as a "Release 1".
Since I'm writing a paper and not a documentation, I clearly don't need the release information. Unfortunately, it is very hard to find information on how to customize Sphinx latex output.
Does somebody know how to do it?
To suppress the release info at the top of your Latex output, you need to set the release and latex_elements['releasename'] to empty strings in your conf.py. So you might add or modify something like this in conf.py:
release = ''
latex_elements = { 'releasename': '' }
Then the release info will be hidden.
As of Sphinx 1.5 something, the workaround of setting an empty string stopped working - at least in my case (I had used it to suppress printing "Release " on the title page) . However, setting release to a blank space does work for me. There's more discussion of it here in the Sphinx-Users group: https://groups.google.com/forum/#!topic/sphinx-users/L5PUfwVu8f0
and there was a related bug report filed: https://github.com/sphinx-doc/sphinx/pull/4411
The bellow lines eliminate also the comma in the header. Add them in your conf.py file:
latex_custom = r'''
\makeatletter
\fancypagestyle{normal}{
\fancyhf{}
\fancyfoot[LE,RO]{{\py#HeaderFamily\thepage}}
\fancyfoot[LO]{{\py#HeaderFamily\nouppercase{\rightmark}}}
\fancyfoot[RE]{{\py#HeaderFamily\nouppercase{\leftmark}}}
\fancyhead[LE,RO]{{\py#HeaderFamily \#title}}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\makeatother
'''
latex_elements = {'preamble': latex_custom}
Such a solution affects only the header.
If you want to remove the release sign also from the front page use the solution provided by ddbeck.
You can use stopwords - Stopwords are the words that will not be indexed.
http://sphinxsearch.com/docs/current.html#conf-stopwords

Resources