Why whitespace denotation of blocks doesn't work.

Georg Mischler schorsch at schorsch.com
Mon Jun 26 04:41:10 EDT 2000


Courageous wrote:
>
> > Very cool.  But as long as you are patiently explaining things,
> > can you tell me how you generated the "»" character inside gvim?
> > The  "Alt-0187" trick did not seem to work.
>
> It's:
>
> <ctrl-V>187

Something related that I just played around with:

If you want vim to warn you when you are mixing spaces and
tabs in a file, you can use the following:

  syn match pyTabSpace "\t\t*  *" contains=pySpaceTab,pyInitTab
  syn match pySpaceTab "  *\t\t*" contains=pyTabSpace,pyInitSpace
  syn match pyInitSpace "^  *"    contains=PySpaceTab
  syn match pyInitTab "^\t\t*"    contains=PyTabSpace

  hi link pyTabSpace    Error
  hi link pySpaceTab    Error
  "hi link pyInitSpace   Error
  "hi link pyInitTab     Error

This will hightlight any combination of tabs and spaces
in an annoying color, so you get motivated to fix them.
If you want to avoid either leading spaces or tabs on
any line altogether, then you can uncomment one of the
last two lines, to your choice (remove the '"').

Typically, those lines go into the vim-5.x/syntax/python.vim
file of your installation, so they take effect every time
you open a python file (the syn and hi[light] sections
are seperated in there, but that's hard to miss).
It would actually be niceto encapsulate this in some ifdef
clauses, so that the user can configure the highlighting
in his .vimrc file. Maybe another time...

Most of this will work fine together with the special tab
display explained in the post that led to the above,
except that only the spaces will get the error highlighting
if you have "listchars=tab:xxx" and "set list" activated.
But then, this means that you prefer tabs anyway, so the
result should still be useful.


Have fun!

-schorsch

--
Georg Mischler  --  simulations developer  --  schorsch at schorsch.com
+schorsch.com+  --  lighting design tools  --  http://www.schorsch.com/


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list