Ad blocker interference detected!
Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers
Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.
Sometimes you may need to keep multiple copies of the same file at different locations in sync. For instance, if you are editing the file
And you need to sync the changes in this file to
after each edit, or you have mounted two hosts using sshfs as:
/mnt/sshfs/host0/ and /mnt/sshfs/host1/
and you'd like to simultaneously edit a file
path/to/file.txt at the same location under the two directories, you can open the file
path/to/file.txt using Vim and then before any edits, run the command:
:autocmd BufWritePost <buffer> w! <path where the duplicate would be written>/%
This will ensure that everytime you execute write the changes to the current buffer, the same changes will also be written to the path for the duplicate of the file.
If you happen to need this functionality often, you can add a custom command to your vimrc, like so:
command -nargs=1 -complete=dir DuplicateAt autocmd BufWritePost <buffer> w! <args>/%
This will define a new command
DuplicateAt which can be invoked as:
After which any writes to the current buffer will also be written to the file path of the current buffer under the directory