The Stack Overflow podcast is back! Listen to an interview with our new CEO.
6

Okay I've done it: It all has to do with ctags: First create two files called foo.c and foo.h to test it: In foo.h write down: int bar(void); In foo.c write down: int bar(void) { /* */ } And in the directory where those two files is, execute: ctags --list-kinds You get a long list of languages with there types of tags. Find C. Notice the following ...


6

The configuration of C indenting in Vim is controlled by the cinoptions option. That particular aspect of indenting is controlled by the l (lower-case L) flag. When set to any value other than 1, it will "align with a case label instead of the statement after it in the same line." So, you can get the indenting style you want by putting this in your ~/.vimrc ...


4

I think what you are looking for is a plugin like tagbar, which can create a sidebar to display all the functions, struct/class, macros, etc. It also allow you to click (or press enter on) the tag and then jump to the definition.


3

You can enable code folding using the vim option: set foldmethod=syntax This reduces the amount of code you see at once and makes it manageable. After enabling code folding, use below commands for opening and closing folds: The commands zc (close), zo (open), and za (toggle) operate on one level of folding, at the cursor. The commands zC, zO and zA are ...


3

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 rules in my local vimrc? for more details on that): syn keyword cppWINAPI SetWindowLong syn keyword cppWINAPIConst WM_CREATE syn keyword cppWINAPItype HGLOBAL hi ...


3

Did you have a look at syntax/doxygen.vim? This is where doxygen highlighting is defined. What you need to do then, is to add a file for pclint in ~/.vim/syntax/, and a syntax rule inspired from the one in syntax/synload.vim which is: au Syntax c,cpp,cs,idl,java,php,datascript \ if (exists('b:load_doxygen_syntax') && b:load_doxygen_syntax) ...


3

Whew, this one was fun! :g/.*\n^{/yank A<cr>:bn<cr>pkdd:%s/$/;/<cr>:g/::/d B<cr>A<cr><cr>class <cr>{<cr>};<esc>"BP:%s/[^ ]\+:://<cr>j%jyt(kk$p=ipjA<cr>public:<esc> You can go ahead and map that to a single keystroke in your .vimrc: nnoremap <C-b> :g/.*\n^{/yank A<cr>:bn<...


2

I think you might solve your problem with the Omni Completion function working with a program like exuberant ctags. The idea is to generate a tags file containing the different classes, constants, fields, etc... of your code and letting Vim use this list to generate the autocomplete suggestions. To do so: Install exuberant ctags: $ sudo apt-get install ...


2

This looks like issue 281 and should be fixed with the latest runtime updates. So make sure to update your runtime files and check again.


2

The :GOTOIMPL command from lh-cpp is able to jump to a function definition from its declaration, or to provide a default empty definition in the case none was found. Some features I can think of: The command already understands comments, exception specifications, keywords that shall not be copied (but possibly copied within comments)(virtual, static, ...)....


2

That looks like issue 281 and should be fixed with newer versions of Vim 7.4


2

The way built-in types are declared is very simple. From /usr/share/vim/vim74/syntax/c.vim: syn keyword cType int long short char void syn keyword cType signed unsigned float double " [..etc..] And then later on it sets a highlight group: hi def link cType Type Adding to this syntax group is easy: :syn keyword ...


2

Open a C file and have a look at cinoptions set cinoptions? Most likely this is empty. Now add t0. set cinoptions+=t0 Reformat your C code, and the type should not be indented anymore. See :help 'cinoptions' and :help cinoptions-values. There you find that indenting the type by one 'shiftwidth' is the default (when on line for it own). If cinoptions is ...


1

Since I ran this linter as an external command and it gave me the same delay to go through the file, I assume it is just really slow. So that's a shame... P.S If you got any solutions on how to fight this delay in large files please feel free to comment below. Thanks Edit: I now use ccls linter, it is fast (at the cost of big cache for every project, but ...


1

Tagbar can help to navigate through a large number of functions in one single file. Among other features, it supports sorting by name or line number, which I find very helpful. marks can also be a great help in navigating back and forth in a large file. See :h marks or http://vimdoc.sourceforge.net/htmldoc/motion.html#mark for more details. If you see the ...


1

In addition to ctags-based plugins like Taglist i use cscope. Some plugins may be useful: like cscope_macros and CCTree. Before using ctags or cscope you have to make tags file and cscope database, see links above. Although these tools are pretty old, they work just fine with many modern C implementations. Also don't forget about marks you can set on ...


1

Something that I am doing is using Plugin Gutentags : Used for creating tags across the project from root folder. Plugin Tagbar : Used for navigating within the files. Plugin Ack : Used to search within whole project. You can find my whole set up @ here


1

There exist many ways to define snippets for control statements: via abbreviations or via snippets. I remember a Q/A about abbreviations versus snippet plugins. TL;DR: We can achieve the same things with both. The main difference is that snippet plugins provide a much simpler way to define maintainable code snippets. For instance, in my lh-cpp plugin you ...


1

We need more details. Header files aren't supposed to contain function definitions, in C. Function declaration, yes, but definitions, unless they are inlined, no. Could it be related to YCM? YCM isn't able to jump to a function definition that isn't in the same translation unit as the current file. For this, you'll need to index the files in your project. ...


1

There is a dedicated plugin for switching to header files: https://www.vim.org/scripts/script.php?script_id=31


1

After some detective work I tracked down the cause of my issue being that I had a .vim file in my plugin directory that redefined OperatorChars, which broke the syntax based folding for C and C++.


1

I did define VimFold4C that tries its best to fold C & C++ codes. The caveat is when we are modifying the code: I'm using caches in order to speed up the fold processing, but alas it has quirks.


1

I'd like vim to recognise this formatting and indent next line properly. Normally, Vim doesn't recognise the curly brace at the end of line as end of block and use the same indent as previous line Vim does recognize the curly brace at the end of the line if it is configured to do so. The most relevant option on this regard is the 'autoindent' (see :help ...


1

In the file /usr/share/vim/vim74/syntax/c.vim, I changed line 466: hi def link cCppOut Comment to hi def link cCppOut Macro and everything looks fine now. I got no idea why there are some c++ highlights in c.vim.


1

I don't know why that happens but you can find out where it happens by moving the cursor to the culprit '0' and issuing the following command :execute "verbose highlight ".synIDattr(synID(line("."),col("."),1),"name") excecute allows you to build a string and execute it as a command verbose followed by some setting will let you know where that setting was ...


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