Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Mar 2001 17:43:48 -0600
From:      Christopher Farley <chris@northernbrewer.com>
To:        hawk <hawk@fac13.ds.psu.edu>
Cc:        Andrew Hesford <ajh3@cec.wustl.edu>, freebsd-questions@FreeBSD.ORG
Subject:   Re: vim highlighting in a regular xterm?
Message-ID:  <20010308174345.A63214@northernbrewer.com>
In-Reply-To: <200103082300.f28N0oW59932@fac13.ds.psu.edu>; from hawk@fac13.ds.psu.edu on Thu, Mar 08, 2001 at 06:00:50PM -0500
References:  <20010308161412.A62961@northernbrewer.com> <200103082300.f28N0oW59932@fac13.ds.psu.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
hawk (hawk@fac13.ds.psu.edu) wrote:

> Yes, I have that one.  What I'm after, though, is to automatically 
> indent the next line by another three spaces after a do, and to come 
> back 3 spaces after an end do, and the like.  emacs does this, which 
> meant I fell into a habit of writing in emacs and editing in vim . . .
> but I'd like to get away from emacs entirely (I don't even have it 
> installed on this machine at the moment . . .)

My install of Vim6, I believe, has a bunch of plugins in
/usr/local/share/vim/vim60v/ftplugin, including a C language plugin.
This is automatically loaded when editing a file with a .c extension if
you have this line in your .vimrc:

filetype plugin indent on

It does 'smart' indenting and syntax highlighting. See also the
'cindent' option in the Vim manual. 

I've attached some sample C code I entered. I did not hit the tab key
once! (The only 'flaw' was that it did not unindent after the 'break' in
the 'switch', but otherwise, it looks pretty good. You can customize
your indentation preferences, too.)

int
main(argc, argv)
   int argc;
   char *argv[];
{
   register int baselen, len, rval;
   register char *p, endp;
   struct stat sb;
   int ch;
   char path[MAXPATHLEN];

   while ((ch = getopt(argc, argv, "fiv")) != -1)
      switch (ch) {
         case 'i':
            iflg = 1;
            fflg = 0;
            break;
         case 'f':
            fflg = 1;
            iflg = 0;
            break;
         case 'v':
            vflg = 1;
            break;
         default:
            usage();
      }
   argc -= optind;
   argv += optind;

   if (argc < 2)
      usage();

   /*
    * If the stat on the target fails or the target isn't a directory,
    * try the move. More than 2 arguments is an error in this case.
    */
   if (stat(argv[argc - 1], &sc) || !S_ISDIR(sb.st_mode)) {
      if (argc > 2)
         usage();
      exit(do_move(argv[0], argv[1]));
   }
   /* etc, etc... */
}
-- 
Christopher Farley
www.northernbrewer.com

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010308174345.A63214>