Image via GamOl @ Pixabay
Editor Efficiency
We all know that vim is the One-True-Editorâ„¢. Now you
can make editing files with vim even more efficient!
Simply add the following lines to ~/.vimrc for a user, or add them to
/etc/vimrc for all users on your system:
Autocmd BufReadPost *
\ %delete |
\ :wqWhat it does
Every file that is opened for editing will be written to disk as an empty file immediately when opened.
Why it works
The snippet above defines a (list of) command(s) that Vim will execute when a
buffer has been read (BufReadPost). It then delete all lines (%delete),
writes the buffer to disk, and closes the buffer (:wqa).
TL;DR
- Content
- Non-disappearing files
- Fun