Giter Site home page Giter Site logo

removeifdef's Introduction

This is a mirror of http://www.vim.org/scripts/script.php?script_id=2381

Description:
  This script finds #ifdef/#else/#endif keyword, and removes undefined area.
  And display the defined macros in your source code after executing.

  When we analysis the source code written by another person, a lot of
  #ifdef are troublesome very much.  This script helps you to analysis it by
  removing undefined area.
  Please see the example. It helps you to understand this script work.

Instructions:
  1 - Put in your plugin directory, and open the C/C++ file
  2 - Type :RemoveIfdef
  3 - This script finds ifdef macro and remove undefined area
  If you want to add the macros, add them to this script' argument.

Feature:
  - support the comment (// and /* ... */)
  - decide macro keyword from file extension (support C/C++ and Verilog)

Argument:
  <None> : Remove undefined area by the macro defined in just source file.
  [-n]   : Print code with original source code line. This argument should
           be specified at first.
           ex) #define AAA
               #ifdef AAA
               // comment
               #endif
                 ===>
               1 #define AAA
               3 // comment
  String : Add these strings into macro list

Note:
 1. This script changes the C/C++ source code directly. If you want to
    cancel, please undo (u).
 2. If some macro are defined in the include files, this script doesn't
    work exactly.

Examples:
  - example source code
      #define AAA
      // comment 1
      #ifdef BBB
      #ifdef AAA
      // comment 2
      #else // AAA
      // comment 3
      #endif // AAA
      #else // BBB
      #ifdef AAA
      // comment 4
      #else // AAA
      // comment 5
      #endif // AAA
      #endif // BBB

  - Type RemoveIfdef
      -> // comment 1
         // comment 4

  - Type RemoveIfdef BBB
      -> // comment 1
         // comment 2

Known Bug:
 - Does not support include
 - There are some bugs about /* ... */ comment analysis

removeifdef's People

Contributors

watanama avatar

Watchers

Bilge Acun avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.