Coping with Tabs

Since tabs (at least at the moment) are a reality in Webware, perhaps we can collect some practical tips for coping with them. It probably makes sense to collect these by editor.

-- JasonHildebrand - 27 Sep 2002


?? why can't we use spaces? I use spaces for my Python coding using Vim, and I use WebKit. I don't seem to have any trouble.. -JamesBecker


You can use spaces in your own Webware-based application -- no problem. But if you need to modify Webware itself, you'll run into trouble if you mix tabs and spaces.

-- JasonHildebrand - 15 Apr 2004

Vim

To teach Vim to switch to "noexpandtabs" mode when editing a file in any subdirectory of "Webware", add these lines to your ~/.vimrc

autocmd BufEnter */Webware/* set noexpandtab
autocmd BufLeave */Webware/* set expandtab

sed

Converting python files from tabs to spaces is a snap.

> cd ~/dev/Webware
> for file in `find . -name "*.py"`
do
    sed -e "s/^V<tab>/    /g" $file > $file.new     # hit ctrl-v and the tab key after the first slash
    mv $file.new $file
done

--VictorNg April 15, 2004

(un)expand

The GNU Coreutils contains the utilties expand and unexpand convert tabs to spaces and vice-versa. A tab is considered to align at specific columns, by default every eight columns or four columns with option -t4, so the specific number of spaces that correspond to a tab depends on where those spaces or tab occur. Unless you specify the -a option, unexpand will only entab the initial whitespace (which goes along with the Webware styleguides).

--ChrisZwerschke July 26, 2005

DrPython

The Editor/Mini-IDE "DrPython" supports converting from tabs to spaces and vice versa via the menu entries "Edit - Whitespace - Set indentation to tabs..." and "Edit - Whitespace - Set indentation to spaces..."

--ChrisZwerschke July 26, 2005