11 votes
Accepted

How do I align C++ comments to be compliant with Google styling?

clang-format is a command line tool that formats c++ code. One of the default formatters is google. clang-format -style=google There are plugins that would allow you to run clang-format in vim. One ...
FDinoff's user avatar
  • 1,936
10 votes

Quick search, limited to a C++ function

Here's how I would do it. Add this to your .vimrc vnoremap if [[O][ Explanation: vnoremap means map the left hand side if to the right hand side [[mO][ while you're in visual mode. if means In ...
DJMcMayhem's user avatar
  • 17.2k
10 votes

Competitive Programming Vimrc is too long

set nocp is not actually needed if your vimrc is located at ~/.vimrc or ~/.vim/vimrc. Many of your commands can be abbreviated even further sy on colo torte se rnu nu nowrap hi=1000 cb=unnamed si ts=...
Mass's user avatar
  • 13.6k
9 votes

Why doesn't YouCompleteMe complete function paramters?

Finally found it! Completing parameters is not a part of the YCM behaviour. See this YCM issue. There's an old fork from oblitum which could grant this feature. That's what misled me. Unfortunately,...
hippunk's user avatar
  • 191
9 votes

How to get intelligent C++ auto-completion?

One option (what I currently use) I don't use YouCompleteMe anymore. coc-clangd is much better and simpler. Today I use coc.nvim + coc-clangd instead. Another option (what I used to use) YouCompleteMe ...
oblitum's user avatar
  • 276
8 votes

Jumping to start/end of function definition in C++

As we cannot expect C++ code to have their function-scope brackets on the first column, we cannot rely on the default behaviour of ]] and ][. A few weeks ago I've added this feature into lh-cpp. I ...
Luc Hermitte's user avatar
  • 16.7k
8 votes

Quick search, limited to a C++ function

DJ McMayhem's solution inspired me to write my own that relies on ctags and on matchit to do a proper analysis of function boundaries. The difficult part has been already done by lh-dev and lh-tags ...
Luc Hermitte's user avatar
  • 16.7k
8 votes

How can i compile cpp using vim

(I've answered this question so many times that I've lost the count, and impossible to find a complete answer in the lot... I'll bookmark this answer this time...) Everything starts with Vim quickfix ...
Luc Hermitte's user avatar
  • 16.7k
7 votes

How do I add skeleton text to new vim files?

Skeleton text from an existing file can be added to a new file by inserting the line autocmd BufNewFile *.cpp r C:\(full file path of skeleton text file) into the vimrc. The BufNewFile event does ...
electriccello's user avatar
7 votes
Accepted

Competitive Programming Vimrc is too long

The first line really should be runtime defaults.vim. This is a standard file and it must be present in all Vim installations. Among other things, it saves from typing syntax on filetype plugin indent ...
Matt's user avatar
  • 19.5k
6 votes
Accepted

How to disable YouCompleteMe's error checking?

The g:ycm_show_diagnostics_ui variable controls this: The *g:ycm_show_diagnostics_ui* option When set, this option turns on YCM's diagnostic display features. See the _Diagnostic display_ section in ...
muru's user avatar
  • 24.5k
6 votes
Accepted

Plugin to display a smarter method tag list

I cannot provide an answer different to the one I gave in other similar questions. While tag-based plugins may present a complete list of existing overloads in a way much more ergonomic than :tselect ...
Luc Hermitte's user avatar
  • 16.7k
5 votes

How do I add skeleton text to new vim files?

Indeed, template expander plugins will help you in this task. :read is the step 0 of template expander plugins. For instance, mu-template will try to include foo.h from foo.cpp if foo.h is detected. ...
Luc Hermitte's user avatar
  • 16.7k
5 votes

Search and replace, but ignore text in quotes

It can be done by testing the syntax name behind the variable to replace: :%s/variable/\=(match(map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")'), '\cstring')==-1 ? 'NEw' : submatch(0))/...
Luc Hermitte's user avatar
  • 16.7k
5 votes

Using the % command in c++

You can force a motion to be linewise; then, the % would include the full last line, including the trailing ;, for example yV%. Unfortunately, if you use the matchit plugin, that doesn't work any more,...
Ingo Karkat's user avatar
  • 17.4k
5 votes
Accepted

Navigation with Tagbar

A variety of methods are at your disposal There are some very useful commands listed here, most notably [I, which will display all lines in the current and all included files containing the keyword ...
ZeroKnight's user avatar
  • 1,051
4 votes

Vim, ctags and overloading

The documentation (:help ctrl-]) says: When there are several matching tags for {ident}, jump to the [count] one. When no [count] is given the first one is jumped to. g] may not be what you are ...
romainl's user avatar
  • 36.9k
4 votes

Vim syntax highlighting of numeric literals with single-quote digit separators

The vim-jp/vim-cpp repo included this change in July 2016: syn match cNumber display contained "\d\('\=\d\+\)*\(u\=l\{0,2}\|ll\=u\)\>" syn match cNumber display contained "0x\x\('\=\x\+...
Martin Tournoij's user avatar
4 votes

syntastic C++14 support

In my .vimrc, I have: let g:syntastic_cpp_checkers = ['gcc'] let g:syntastic_cpp_compiler = 'gcc' let g:syntastic_cpp_compiler_options = '-std=c++14' And, if you have YCM enabled: let g:...
tuxtoriel's user avatar
  • 181
4 votes
Accepted

Is it possible to get the rule (cinoptions) that govern the indentation for a specific line in vim

" tell which cinoption take effect for current line com! WhichCinoption call s:which_cinoption() function s:which_cinoption() abort " test if cindent take effect if !empty(&indentexpr) ...
dedowsdi's user avatar
  • 6,058
4 votes

Quick search, limited to a C++ function

Finding the beginning and end of a function can be difficult, especially in a language without a function keyword… and many conflicting indent styles. If your function ends with a closing brace alone ...
romainl's user avatar
  • 36.9k
4 votes
Accepted

Remove colon from keyword in C++ file?

You could put setlocal iskeyword-=: inside ~/.vim/after/ftplugin/cpp.vim Loads automatically when you open files where the filetype is cpp. If it doesn't work, try setting filetype plugin on. ...
Wolfie's user avatar
  • 657
4 votes

Jumping to start/end of function definition in C++

I'm not aware of anything direct and foolproof. It may very well exist in a plugin somewhere, of course. ][ will take you to the next closing curly brace in column one. If your code is properly ...
Dan J.'s user avatar
  • 206
4 votes

Compiling and running multiple c++ files from vim

:make doesn't have to actually use a Makefile. Try something like: :let &makeprg = "g++ *.cpp -o [Filename]" You can then run the command with :make and if desired you can set up a normal mode ...
Rich's user avatar
  • 30.4k
4 votes

How to change Operator highlight color in Vim?

It indeed looks like cppOperator links to Operator which links to Statement (-> :hi cppOperator), but I've never seen these operators displayed differently... It's just for the keywords. See syn list ...
Luc Hermitte's user avatar
  • 16.7k
4 votes
Accepted

Understanding indenting rules for C++ files

Indentation of C++ (and also C, Objective-C and even Java) is typically handled by enabling the 'cindent' option, which uses Vim's built-in C-indenting implementation, which recognizes elements of ...
filbranden's user avatar
  • 27.5k
4 votes

Competitive Programming Vimrc is too long

There are a few interresting things already in the default C and C++ filetype plugins -> filetype plugin indent on. This should enable smart indenting. No need anymore to use tabs, which could be ...
Luc Hermitte's user avatar
  • 16.7k
3 votes

Quick search, limited to a C++ function

An imperfect solution is using folds. Fold everything: set foldmethod=syntax set foldlevel=0 set foldminlines=0 Tell Vim not to open folded areas for search results: set foldopen-=search And then ...
muru's user avatar
  • 24.5k
3 votes

Quick search, limited to a C++ function

Another way: use ctags etc. to find the target function, go there move cursor forward inside the function body use Osyo Manga's search operator (depends on vim-operator-user) to only search inside ...
VanLaser's user avatar
  • 9,530
3 votes

How can I highlight WinAPI functions in C++?

You've already found how to highlight these types from the link you've posted in your question; by adding these lines to after/syntax/c/winapi.vim (see How can I add additional syntax highlighting ...
Martin Tournoij's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible