[NCLUG] Looking at programming languages...

Chad Perrin perrin at apotheon.com
Sun Jan 20 16:10:27 MST 2008


On Sat, Jan 19, 2008 at 04:59:18PM -0700, Sean Reifschneider wrote:
> On Fri, Jan 18, 2008 at 11:47:00PM -0700, Chad Perrin wrote:
> >I'm aware of <Ctrl><v>+<Tab> -- but what I'm hoping for is a method for
> >using tabs without having spaces automatically turned into tabs that
> >doesn't involve turning one keystroke into three keystrokes.
> 
> I really don't have a good feel for where exactly vim is falling down for
> you, but it feels like you just need to get more familiar with the various
> vim tab-related settings like smarttabs, expandtab, and autocmd.  For
> example, when I'm editing text documents I have expandtab enabled, but when
> I'm editing makefiles vim automatically detects this and does not expand
> tabs into spaces.  So, with these settings vim just works for me...

The problem is that there are cases where I need both tabs *and* spaces,
so that I effectively need Vim to be smarter about when it turns tabs
into spaces and when it doesn't.  At least, that's how it looks when you
assume that Vim cannot avoid turning spaces into tabs when doing
automatic indentation.

The logical way to do it would be this:

  1. If I type a tab, it keeps it as a tab.  If I hit Enter at the end of
  a line with a tab, it automatically adds a tab at the beginning of the
  next line.

  2. If I type eight spaces, it keeps it as eight spaces.  If I hit Enter
  at the end of a line with eight spaces, it automatically adds eight
  spaces at the beginning of the next line.

Instead, what Vim does is this without expandtab enabled:

  1. If I type a tab, it keeps it as a tab.  If I hit enter at the
  beginning of a line with a tab, it automatically adds a tab at the
  beginning of the next line.

  2. If I type eight spaces, it keeps it as eight spaces.  If I hit Enter
  at the end of a line with eight spaces, it automatically adds *a tab*
  at the beginning of the next line.

. . . and what Vim does is this *with* expandtab enabled:

  1. If I type a tab, it turns it into eight spaces.

  2. If I type eight spaces, it keeps it as eight spaces.

  3. If I hit Enter at the end of either one of those lines, it
  automatically adds eight spaces at the beginning of the next line.

At least, I haven't found a way to make it work the way I like (the first
example).

-- 
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
McCloctnick the Lucid: "The first rule of magic is simple. Don't waste your
time waving your hands and hopping when a rock or a club will do."



More information about the NCLUG mailing list