This command replaces some text in all my buffers:
:bufdo %s/some_text/other_text/ge | update
When running this command, the buffer of the current window is changed to the last buffer affected by :bufdo
, as explained in :help :bufdo
:
The last buffer (or where an error occurred) becomes the current buffer.
I know it's possible to prevent the buffer from being changed, but I don't remember how.
You can save off the current buffer before running the command, then jump to it after:
:let buf=bufnr('%') | exec 'bufdo some_command' | exec 'b' buf
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With