Skip to content

Local Setup: Vim and git

Hunter Rancourt edited this page Aug 19, 2020 · 1 revision

The Vim plugins used below will add several helpful features to Vim including:

  • Changing the git message title text color after the 50th character (following Github's standards)
  • Wrap git message body text at 75...ish characters

Vim Package Manager

  1. Download vim-plug
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

note: You may be able to skip curling the file as the config (below) should automatically download it for you

  1. Create a vim-plug config file
    1. Run vim ~/.vim/.vimrc-vim-plug.vim
    2. Press i to enter Vim's insert mode and paste the following:
    " vim-plug info https://github.com/junegunn/vim-plug
    
    " Make sure vim-plug is installed
    if empty(glob('~/.vim/autoload/plug.vim'))
      silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
        \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
      autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
    endif
    
    " Specify a directory for plugins
    call plug#begin('~/.vim/plugged')
    
    " Any Valid github url is allowed and you can use shorthand as well
    
    " Git Tools - adds git commit message line highlighting up to 50 chars and other useful features
    Plug 'tpope/vim-fugitive'
    
    " Sensible Vim - adds some generally accepted good changes to vim's config
    Plug 'tpope/vim-sensible'
    
    " Initialize plugin system
    call plug#end()
    1. Save and close: press escape then :wq and press return
  2. Create a .vimrc file
    1. Run vim ~/.vimrc
    2. Press i to enter input mode and paste the following:
    " vim-plug vim plugin/package manager
    try
      source ~/.vim/.vimrc-vim-plug.vim
    catch
      " file not found or error, fail silently
    endtry
    
    " You may add any other mods you'd like to make here
    1. Save and close: press escape then :wq and press return
  3. Now open a junk file in vim vim delete-test (we wont save this)
  4. Now we'll install the plugins from our vim-plug config
    1. Type :PlugInstall and press return note: You may be able to tab complete the command
  5. Once the install completes you can quit vim-plug by typing :q and pressing return
  6. Finally quit vim itself without saving the file by typing :q and pressing return

note: You may need to force quit, to do this type :q! and press return

Clone this wiki locally