Tip #249: C/C++: Quickly insert #if 0 - #endif around block of code
tip karma |
Rating 9/6, Viewed by 674
|
created: |
|
May 22, 2002 17:58 |
|
complexity: |
|
basic |
author: |
|
David Thompson |
|
as of Vim: |
|
5.7 |
One of my favorite macros that I use in vim (and vi) inserts a #if 0 #endif sandwich
around a block of code. I always map this to the 2 key sequence ;' which is the
semi-colon followed by the single quote. Look at your keyboard, you will notice
these keys are adjacent to one another. I like this mapping because it's very fast,
my fingers easily roll from one key to the next, obviously YMMV.
To use this mapping, go to the line of code that you want the '#if 0' to be on, type
ma to mark this line with the marker a, then move to the line that should be last line
just above the '#endif' and press ;'
" insert #if 0 - #endif around block of code
map ;' mz'aO<Esc>i#if 0<Esc>'zo<Esc>i#endif<Esc>
--
David Thompson
[email protected]
<<Auto-save the current buffer periodically. |
One big window >>
Additional Notes
|