May 24

VIM Configuration for Writers

Posted by seditiousbroom

This article is not meant as defense for using vim as a writer's tool. Instead, it offers solid version control in a single backup directory. Each time vim is used to view or edit a file it creates a new backup file in the $home/archives folder. Each backup file includes an ISO 8601 formatted date stamp in the filename.
  1. # cd $home
  2. # mkdir archive
  3. Edit .vimrc to include the following:
    "Version control backup with ISO 8601 date stamp in filename
    set backup
    set backupdir=$HOME/archive
    set directory=$HOME/archive
    au BufWritePre * let &bex = '_' . strftime("%Y-%m-%d") . '~'
A few other .vimrc options to consider:
  • "Enable the backspace key to delete previous characters
    set bs=2
  • "As-you-type spell check usingdefault language dict if installed
    set spell
  • "Word wrap that only adds line break when you press Enter
    set formatoptions=1
    set lbr
  • "Enable incremental search without case sensitivity except explicit caps
    set incsearch
    set ignorecase
    set smartcase
  • "Buffer scrolling
    set scrolloff=3