Hi all,

An occasionally-recurring annoyance when using the normal-mode command  
 > is that, by default, it has no effect on lines that begin with  
'#'.  The documentation for that command is followed by this  
explanation:

         If the 'smartindent' option is on, or 'cindent' is on
         and 'cinkeys' contains '#', shift right does not affect
         lines starting with '#' (these are supposed to be C
         preprocessor lines that must stay in column 1).

This rule about '#' needing to appear in the first column to begin a C  
preprocessor directive does not come from any of the ISO C (89 or 99)  
or ISO C++ language rules.  Instead, the ISO standards state that the  
'#' that begins a preprocessor directive must be the first *non-white  
space, non-horizontal-tab character* following the beginning of the  
source file or following the last new-line character.

The bogus first-column rule is not even specified in the first edition  
of K&R.  Presumably this behavior was put in place to cope with a  
preprocessor bug in some old compiler.  However, ISO conformance is  
pretty ubiquitous these days, so having '0#' by default in cinkeys is  
now an anachronism.  It should be removed because it can cramp  
people's styles.  For example, some people like to indent  
conditionally-compiled code as in:

#ifdef A
         #ifdef FOO
                 #define BAR 1
         #else
                 #define BAR 2
         #endif
#else
         #define BAR 3
#endif /* A */

int n = BAR; /* ok */

Another example:  there are lots of cases where a single macro  
definition spans multiple physical lines, and some of those lines may  
begin with uses of the # operator; e.g.:

#define STR( a, b )     \
         #a              \
         #b

const char * s = STR( asdf, qwer ); /* ok */

It's quite natural to add indentation as we see in the definition of  
STR(), but neither '>' nor '=' have the desired effect.  I can live  
with '=' not doing what I want, but '>' should at least obey.  We get  
that behavior with the aforementioned removal of '0#'.

James Widman
-- 
Gimpel Software
http://gimpel.com



--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui