I have the following mappings:
nnoremap # /___<CR>ciw imap # <Esc>:w<CR><Esc>#
And the following file that I am editing:
foo ___ goo ___ hoo ___
The idea is that I start at the beginning of the file, type
# and I am editing the first
___, then while still in insert mode, I type
# again, and I am editing the next
___, saving between each edit. This works fine, but the problem is that if I make a mistake, and type
u, it undoes ALL the edits and reverts ALL of them back to
___ instead of just the most recent change.
How can I do these mappings in a way so that each time I save, it counts as a separate undo?