How to ignore an autocmd in vim's undo history?
Posted
by
Dave Vogt
on Super User
See other posts from Super User
or by Dave Vogt
Published on 2010-08-06T08:24:41Z
Indexed on
2011/06/26
8:24 UTC
Read the original article
Hit count: 293
I have the following autocommand, which basically strips whitespace at the end of each line. Unfortunately, at each save, it inserts a step into the undo to jump to the beginning to the file, which is quite annoying. Is there a way to make vim ignore jumping around in the following command, so that undoing keeps the cursor in position?
autocmd BufWritePre *
\ let s:bufwritepre_currline = line('.') |
\ let s:bufwritepre_currcol = col('.') |
\ silent %s/\s*$// |
\ call cursor(s:bufwritepre_currline, s:bufwritepre_currcol)
© Super User or respective owner