Thursday, November 3, 2011

Re: increasing/reducing the number of leading white spaces dynamically


that trigger on BufWritePre and BufWritePost, something like (untested)

 autocmd BufWritePre *.py %s/^\( \{8}\)\+/\=substitute(submatch(0), repeat(' ', 8), repeat(' ', 4), 'g')

 autocmd BufWritePost *.py %s/^\( \{4}\)\+/\=substitute(submatch(0), repeat(' ', 4), repeat(' ', 8), 'g')



OK. The key thing is autocmd. Now I have something to start with.

However, looking at these two things, I get confused.
The first one makes sense. Just before "saving" the buffer on disk it changes 8 spaces by 4. Good.
But the second one ... shouldn't it be something like BufRead<whatever> in order to expand 4 spaces to 8 when I start editing the file?

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: