• Arnaud's links
  • Home
  • RSS Feed
  • Tag cloud
  • Login
all links
  • Edit a file in-place in vim - Stack Overflow

    Comment perdre 30 min

    :set backupcopy=yes

    When you want to modify a file, you have two options, each with its benefits and drawbacks.

    You can overwrite the file in place. This does not use any extra space, and conserves the hard links, permissions and any other attribute beyond the content of the existing file. The major drawback of doing this is that if anything happens while the file is being written (the application crashes, or the power goes out), you end up with a partially written file.
    You can write the new version of the file to a new file with a different name, then move it into place. This uses more space and breaks hard links, and if you have write permissions on a file but not on the directory it contains, you can't do it at all. On the flip side, the old version of the file is atomically replaced by the new version, so at every point in time the file name points to a valid, complete version of the file.
    

    http://vimdoc.sourceforge.net/htmldoc/options.html#%27backup%27

    November 23, 2016 - permalink - http://stackoverflow.com/questions/11043534/edit-a-file-in-place-in-vim
    docker file mount vim