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 is 20,000 lines. I can read the code and make sense of it, but I'd rather not. This is only ever a problem in my experience with C. For some reason, in C the file size is absurdly big, and readelf.c isn't alone in this. Is there anything that can virtualize a C file into something sane like a structured project -- I know that's asking for a lot, but it would seem with all the C code in existence someone would have done something like that.

My laptop's terminal can hold ~50 lines. What tools and plugins does vim offer to help navigating files that are in excess of 10k but less than 100k lines?

  • 5
    Code folding can help somewhat, along with tags
    – D. Ben Knoble
    Commented Dec 12, 2018 at 0:07
  • 1
    you can try tagbar . See the screenshot it provided in the page. You can then navigate the functions, structs defined in a sidebar.
    – doraemon
    Commented Dec 12, 2018 at 6:38
  • @LiuSha that's exactly what i'm looking for, if you want to make that an answer I'll accept it. Commented Dec 12, 2018 at 17:59

5 Answers 5


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.


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 similar, but operate on all folding levels (for example, the cursor line may be in an open fold, which is inside another open fold; typing zC would close all folds at the cursor).

The command zr reduces folding by opening one more level of folds throughout the whole buffer (the cursor position is not relevant). Use zR to open all folds.


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


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 important places, folding unwanted parts, gD, *, ]] and similar motions. If you do not want to use any external programs or plugins you can get some preview of file by this

:set foldmethod=syntax

foldmethod sets folding based on C syntax (you can write it in .vimrc) and zM command (in normal mode) folds everything to max level.

For more information see:

:help tags
:help ctags
:help cscope
:help mark-motions
:help folding

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 need to constantly jump between multiple (large) files, Gtags might help you in finding definitions/references across the project.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.