- keep a original state of a file after you open it
- enable ability to undo even if you close a file
- concentrate swap files
mkdir -p ~/.vim/{backup,swap,undo}and place into .vimrc the following
" Enable Backup Files
set backup
set backupdir=~/.vim/backup//
set backupext=.bak
" Enable Swap Files (for crash recovery)
set swapfile
set directory=~/.vim/swap//
" Enable Undo Files (Persistent Undo)
set undofile
set undodir=~/.vim/undo//Say you want to replace all occurrences of the word abc with xyz but abc also appears as ABC or Abc and you want to preserve the current case (e.g. turn ABC to XYZ and Abc to Xyz). All you need is the vim-abolish plugin.
:%S/abc/xyz/gCaution
Note the capital S
mkdir -p ~/.vim/pack/tpope/start
cd ~/.vim/pack/tpope/start
git clone https://tpope.io/vim/abolish.git
vim -u NONE -c "helptags abolish/doc" -c q