I've been trying to make a dot-repeatable (.
) command that should work in both visual and normal mode. The command in question searches for a [] on a line and turns it into a [x], and vise versa.
It works as follows:
:Fill
[] -----> [x]
:Fill
[x] ----> []
So far, I managed to create a command that works both in visual and normal mode as follows:
function Fill()
try
execute a:firstline . ',' . a:lastline . 'snomagic/[]/[x]/'
catch
execute a:firstline . ',' . a:lastline . 'snomagic/[x]/[]/'
endtry
command -range Fill :<line1>,<line2>call Fill()
However, this command is not repeatable when running the .
operator. I've been looking through the documentation :help .
and :help :command
. I tried sourcing the above command from a different file, but I couldn't make that Work. Neither do I understand how to make this command repeatable from other vi.stackexchange questions. Your help is greatly appreciated, thanks in advance!