Questions tagged [filetype-c]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
10
votes
2answers
1k views

Automatically creating functions out of function prototypes from header files

Intro When programming in C and C++ you usually split your function prototypes and actual functions into a .h/.hpp and .c/.cpp file. Sadly it's very tedious to transfer the function prototypes from ...
7
votes
5answers
264 views

How do you navigate large source files with VIM?

First, I'm not asking about performance. I'm looking for something that will help me, mentally, get into large C source code files that I'm not yes accustomed to. Take for example readelf.c. This file ...
7
votes
1answer
2k views

Jumping from function definition tag to prototype tag

As far as I understand Vim has a built-in support for tags (ctags in this case) Now I have a common C source and C header file. The header file has void foo(void); and the source file has void foo(...
5
votes
2answers
591 views

Vim `cpp` Syntax highlighter prematurely ends macros mid-word

NOTE: This question is a "manual migration" from here: https://superuser.com/q/875751/199803 My Vim syntax highlighter for ft=cpp is prematurely ending some macros mid-line. For example: (The ...
5
votes
1answer
2k views

Vim syntax highlighting for custom C types

I want to use syntax highlighting for custom C types. Based on my coding convention, types can occur in the following places: typedef type1 type2; (static | extern | register | volatile)? type ...; ...
4
votes
1answer
263 views

Customize vim to automatically check function name against its prototype

I wonder if there is any method that I can use to check a function name against its prototype, which may help a lot when I make typo. For example, I once wrote a function prototype this way:void ...
4
votes
1answer
648 views

Indenting c/c++ using lisp indentation style

I want to write c++ code in vim using lisp indentation style (closing curly braces on the same line as last statement) but I can't figure out how to configure indentation to use that style. Is there ...
3
votes
1answer
320 views

Auto Indent (the = key) of C switch block

For the following switch block: If I select the switch block and apply the auto format command, the = key, I get the following: The block is formatted correctly in the first image, but it gets ...
2
votes
3answers
625 views

Color change in the middle of #define [duplicate]

Every time I have a '0' character in a #define preprocessor directive in C, I get a change of color. Neither the font nor color scheme have influence on it. It is starting to annoy me. Does anyone ...
2
votes
1answer
214 views

How do I highlight pc-lint comments in C/C++

How do I mimic the behavior of Doxygen comment highlighting for PC-lint comments? Comments are in the following formats: /*lint ... */ //lint ... /* LINTLIBRARY */ /* ARGUSED */ /* VARARGS[N] */ <-...
2
votes
1answer
26 views

Vim syntax match changes based on function type name keyword

I've written a C code syntax rule to highlight function names in function definitions as such: This is the syntax rule written in ~/.vim/syntax/c.vim: syntax match cCustomFunc /\w\+\s\+\zs\w\+(/he=e-...
2
votes
0answers
216 views

Tools for working with C #ifdef preprocessor directives?

I want to work with a C code with a lot of #ifdef directives. I wonder if there is a program, that will show me, which of these #ifdef's will be left in the code, and which will be cut out by ...
1
vote
1answer
34 views

Indenting a c file adds spaces before function's type?

Open a c file and then type: int main and then hit: gg=G It becomes int main Is this an intended behavior? Is there a way to change this? I prefer it to be retained as is because most ...
1
vote
1answer
33 views

ALE + clangtidy + large file = big delay when linting

I am using ALE plugin with clangtidy linter to lint my C code and whenever I save my file and this linter gets activated it takes around 3-4 seconds for it to check for errors. File in question is ...
1
vote
1answer
220 views

folding, curly bracket under the function name

I have these two functions void function_one(){ return; } void function_two() { return; } when I use zM to fold the functions I get +-- 3 lines: void function_one(){-- void ...
1
vote
0answers
140 views

Why does cindent align statements to closing } in switch case?

I prefer this indentation style for switch cases with local variables: switch (expr) { case CONST_BLAH1: { int decl; // scope local to this case stmt; break; case CONST_BLAH2: ...
0
votes
1answer
220 views

How can I highlight WinAPI functions in C++?

How can I add syntax highlight for windows.h C/C++ apis and types? All I've found is a tiny winapi syntax file here.
0
votes
2answers
318 views

Is there a way to open header file in c?

I'm trying to configure vim for programming in C. I currently use YouCompleteMe and Syntastic for programming auto-completion and syntax-checking. But I came up with a problem. I cannot jump to a ...
0
votes
1answer
384 views

Folding doesn't work for C/C++

I've been having a ridiculously hard time getting C/C++ code folding to work with set foldmethod=syntax. To debug my issue I've stripped down my vimrc to only this: set foldmethod=syntax syntax on ...
0
votes
0answers
84 views

Configure Neomake to use gcc for C files and g++ for C++ files

I would like to use gcc and g++ instead of clang and clang++ with Neomake. I found a post for Setting GCC to be the only checker for Neomake but I am not sure if this also makes Neomake use g++ for C+...
-1
votes
1answer
76 views

Insert C/C++ loops and statements templates automatically [closed]

How do I insert C/C++-type loops and statements templates automatically in Vim?