Tip #251: c/c++: align #endif with corresponding #if/#ifdef
tip karma |
Rating -1/1, Viewed by 502
|
created: |
|
May 24, 2002 14:28 |
|
complexity: |
|
basic |
author: |
|
Kartik Agaram |
|
as of Vim: |
|
5.7 |
If you try to impose any sort of alignment on your preprocessor directives, rather than just starting them on column 0, this mapping will align the #endif 'correctly' when you type '#en', start a new line, and bring you back to the correct alignment to edit code.
inoremap <buffer> #en X<BS><Esc>?#if<CR>"zy0^Og0"zpDa#endif<CR>X<BS><Esc>?#end?-1<CR>^"zy0^O0"zpDa
I am reasonably sure this is insensitive to vim options...
<<One big window |
python script to align statements >>
Additional Notes
|