How do I use ifdef-highlighting

This page summarizes the projects mentioned and recommended in the original post on /r/vim

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • ifdef-highlighting

    #ifdef highlighting in c/c++/idl

  • All those vim.org scripts also have a github version https://github.com/vim-scripts/ifdef-highlighting which I tend to use with my plugin manager (although vim.org links also work, I use https://github.com/junegunn/vim-plug but there are others that work similarly, and vim has one built in.) If you do it like this, you don't have to think about how to install it, just add something like Plug 'vim-scripts/ifdef-highlighting' and you're done.

  • vim-plug

    :hibiscus: Minimalist Vim Plugin Manager

  • All those vim.org scripts also have a github version https://github.com/vim-scripts/ifdef-highlighting which I tend to use with my plugin manager (although vim.org links also work, I use https://github.com/junegunn/vim-plug but there are others that work similarly, and vim has one built in.) If you do it like this, you don't have to think about how to install it, just add something like Plug 'vim-scripts/ifdef-highlighting' and you're done.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • vim-matchup

    vim match-up: even better % :facepunch: navigate and highlight matching words :facepunch: modern matchit and matchparen. Supports both vim and neovim + tree-sitter.

  • Bonus tip, check out: https://github.com/andymass/vim-matchup then the #if(def)/#else/#endif can be jumped between using the normal mode '%' command. I think this is very helpful to find matching pairs, especially in unknown code with lots of nested preprocessor macros.

  • vim-lsp-cxx-highlight

    Vim plugin for C/C++/ObjC semantic highlighting using cquery, ccls, or clangd

  • I use coc.nvim with e.g. coc-clangd extension (with https://github.com/jackguo380/vim-lsp-cxx-highlight for extra highlighting, but that might not be necessary anymore with some recent update I think I read somewhere) which has a similar feature, but uses the compiler settings from a compile_commands.json or some configuration file to know which defines are which value, to do this kind of ifdef block highlighting.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts