It seems you basically understand correctly:
": is a readonly register that contains the last executed command.
@: will execute this register. Feel free to read up on this:
:help ": and
Further, your issue is that you want to repeat a command but you are issuing a new command in between,
:write, which obviously overwrites
":. You ask: "Can I get
@: to ignore
:w?". Of course, yes, you can define a new command that uses
histget() and map it to
@:, as is suggested by @Ralf in the comments. However, I will advice that you instead reconsider your own workflow. Instead of changing
@:, try to compose repeatable commands. For instance, instead of
:s/foo/bar/e | update
Here I've added the
e flag, which prevents the substitute command from failing if there are no
foos found. Then I use
:help bar) to add a new command to be executed after, and I use
:update instead of
:write to only write the file if there is a change.
In my opinion, this is a better solution than changing how Vim works.