Tags: Vim Test-file
Stop Vim from Overwriting Extended Attributes
There's a pretty undocumented issue with the Vim editor which affects files containing extended attributes (xattrs).
Vim may overwrite files instead of updating them. In addition to creating
some trouble with inotify watcher and events, this process also clobbers the
extended attributes of a file. This can be problematic if you happen to store
information within the files's xattrs
. For example, I store an MD5 hash in
some of my articles; when I edit an article, the actual checksum will differ
from the one in xattr, and my Perl script will know to update the article on
this website.
This tendency of Vim is controlled by the backupcopy
variable. By default,
backupcopy=yes
for Unix and backupcopy=auto
otherwise. Some distributions
will unset backupcopy
, so it may be necessary to put the following in your
.vimrc
file:
set backupcopy=yes
Now extended attributes should be preserved across writes. To test this, do the following in a shell:
touch test-file
setfattr -n user.attr1 -v v1 test-file
vim test-file # Add some text and :wq
getfattr test-file
Although some claim that this slows down the :w
command, I've not seen a
measurable difference in performance since using this setting.
- Last Modified
- First Written
Related / Browse
- The Item you have Ordered is Out for Delivery
-
Locker
People
January 26, 2019
- 15-November
-
Love
Time
November 15, 2018
- 001
-
Circle
Thoughts
April 24, 2018
- Grounds in the Coffee Pot
-
Thing
I
November 6, 2019
- Setting up a Graphical Sudo Prompt on X.org
-
Sudo
Root
February 5, 2019
- Yumi
-
Name
Wangan
June 2, 2018
- September-14
-
Trial
Today
September 14, 2015