On 11/03/11 15:20, Jose Caballero wrote:
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 might want one of those too, using the BufRead event. The
above two just do
1) change to 4-space
2) write to disk
3) change back to 8-space
However, you might also want to do the same as the BufWritePost
for the BufRead event so that when you start-up with the file, it
converts it into your preferred format.
-tim
--
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