On 27/05/08 20:26, James Widman wrote:
> 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
At least the default 'cinkeys' and 'cinoptions' settings are consistent
with Bram's "house style", as used in the source of Vim. I'm not saying
these are the best defaults -- maybe there are no best defaults -- but
at least they're values which have a meaning to which the Vim user can
relate.
You can always set other defaults to suit your usual programming style,
using ":setlocal" statements in ~/.vim/after/ftplugin/c.vim (for
Windows, replace /.vim/ by /vimfiles/).
Best regards,
Tony.
--
"How many hors d'oeuvres you are allowed to take off a tray being
carried by a waiter at a nice party?"
Two, but there are ways around it, depending on the style of the hors
d'oeuvre. If they're those little pastry things where you can't tell
what's inside, you take one, bite off about two-thirds of it, then
say: "This is cheese! I hate cheese!" Then you put the rest of it
back on the tray and bite another one and go, "Darn it! Another
cheese!" and so on.
-- Dave Barry, "The Stuff of Etiquette"
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---