Getting Started With Vim
Adam Harris
Web Developer at Domo
@adamCoder
adamWadeHarris.com
Brief History of Vim
Line Editors
- TECO 1963
- QED 1965
- ed 1971
- em- editor for mortals
- en
- ex 1976
Vi is Ex
:visual
:vi
Vim
- Vi IMproved
- 1988-1991
- Bram Moolenaar
- charityware
The future?
Vim's Big Ideas
- Extensibility
- Composability
- Modality
Extensibility
- Customizations
- Themes
- Plugins
Composability
- dw- delete word
- d$- delete to the end of line
- cw- change word
- d2w- delete 2 words
- yw- yank word
- ct'- change to single quote
Modality
- Normal mode (command mode)
- Insert mode
- Visual mode
- Command line mode
- Ex mode
Who Shouldn't Learn Vim
- If you can't touch type
- If you're just beginning to learn programming
- If you're in the middle of a big project
- If you're happy with your current editor
Touch Typing
typing.io
Who Should Learn Vim
- If you love the terminal
- If you hate using the mouse
- If you have time to dedicate to getting started
- If you're a continual learner
- If you know someone who uses vim
(you might also want to look into emacs)
How to get started
- Learn the basics
- Version control your dotfiles
- Get some plugins
- Make it pretty
- Use vim for commit messages
Learn the Basics
Books
-
Practical Vim by Drew Neil
Articles
- danielmiessler.com/study/vim
- yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively
- adamwadeharris.com/how-to-learn-vim
Websites
-
vi.stackexchange.com
-
reddit.com/r/vim
Interactive
-
Vim Adventures
-
vimtutor
-
openvim.com
-
:help
Videos
-
Derek Wyatt- derekwyatt.org
-
Vim casts by Drew Neil- vimcasts.org
-
7 Habits For Effective Text Editing 2.0 by Bram Moolenaar
-
More Instantly Better Vim by Damian Conway
-
Smash into Vim- pluralsight.com/courses/smash-into-vim
-
The Art of Vim- upcase.com/the-art-of-vim
https://github.com/LevelbossMike/vim_shortcut_wallpaper
www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html
Version Control Your Dotfiles
dotfiles.github.io
Make a dotfiles repo
dotfiles/
setup.sh
vim/
bundle/
Vundle.vim
colors/
solarized.vim
vimrc
vimrc -> vim/vimrc
Setup script
# This script creates symlinks from the home directory to any desired dotfiles in ~/dotfiles
############################
########## Variables
dir=~/dotfiles # dotfiles directory
olddir=~/dotfiles_old # old dotfiles backup directory
# list of files/folders to symlink in homedir
files="vim vimrc"
##########
# create dotfiles_old in homedir
echo -n "Creating $olddir for backup of any existing dotfiles in ~ ..."
mkdir -p $olddir
echo "done"
# change to the dotfiles directory
echo -n "Changing to the $dir directory ..."
cd $dir
echo "done"
# move any existing dotfiles in homedir to dotfiles_old directory, then create symlinks from the homedir to any files in the ~/dotfiles directory specified in $files
for file in $files; do
echo "Moving $file from ~ to $olddir"
mv ~/.$file ~/dotfiles_old/
echo "Creating symlink to $file in home directory."
ln -s $dir/$file ~/.$file
done
.vim -> /Users/adamharris/dotfiles/vim
.vimrc -> /Users/adamharris/dotfiles/vimrc
dotfiles/
setup.sh
vim/
bundle/
Vundle.vim
colors/
solarized.vim
vimrc
vimrc -> vim/vimrc
Plugin Managers
Plugin Managers
- Vundle
- Pathogen
- NeoBundle
- vim-plug
- VAM (vim-addon-manager)
- oh-my-vim
Install Vundle
$ git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
Put this in your .vimrc
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
# example plugin
Plugin 'tpope/vim-fugitive'
call vundle#end()
filetype plugin indent on
Install Plugins
Plugin 'tpope/vim-sensible'
:PluginInstall
Cool Plugins
ctrlpvim/ctrlp.vim
tpope/vim-commentary
airblade/vim-gitgutter
matze/vim-move
terryma/vim-multiple-cursors
tpope/vim-surround
Yggdroot/indentLine
Other Plugins
- tpope/vim-sensible
- tpope/vim-sleuth
- vim-scripts/IndexedSearch
JavaScript Plugins
- scrooloose/syntastic
- Valloric/YouCompleteMe
- marijnh/tern_for_vim
- maksimr/vim-jsbeautify
- heavenshell/vim-jsdoc
Html Plugins
- docunext/closetag.vim
mattn/emmet-vim
CSS Plugins
- ap/vim-css-color
Git Plugins
- tpope/vim-fugitive
- vimcasts 5 part series on fugitive
Make it Pretty
Install Color Scheme
$ mv solarized.vim ~/.vim/colors/
Bundle 'altercation/vim-colors-solarized'
syntax enable
set background=dark
colorscheme solarized
Manual Installation
Or install with Vundle
Then put this in your .vimrc
Use vim for git commit messages
.gitconfig
[core]
editor = vim
.vimrc
" Turn on spell checking for commit messages
" and automatic wrapping at the recommeneded 72 characters
autocmd Filetype gitcommit setlocal spell textwidth=72
More Stuff
- tmux
- Learn Vimscript the Hard Way by Steve Losh
- Vimium
- Vim Tips - New Tab Replacement
Chrome Plugins
@adamCoder
adamWadeHarris.com