Choosing Vim: How
Here's a scary post for Halloween!
As I previously mentioned, I'm in the process of getting into Vim. Here's how:
These devs, they come at you all "Hey. Hey kid… use my dotfiles"
— Josh Cheek (@josh_cheek) January 23, 2014
I talked to a friend who helped me out by sharing a bunch of recommendations for getting started with Vim. While there are a load of vim plugins out there, I think it is worth adding them one or a few at a time. There is utility in understanding vanilla vim. For example, it's already there on every computer, and better than nano. When you've ssh'd into your VPS and need to make changes, the ability to get around in vim will come in handy. (:E
, for example, is a passable replacement for NERDTree) Also, it is overwhelming and unproductive to have too many plugins for software you are trying to learn.
My setup consists of pathogen along with the following plugins .vimrc
.
https://github.com/kien/ctrlp.vim
https://github.com/terryma/vim-multiple-cursors
https://github.com/scrooloose/syntastic
execute pathogen#infect()
set rtp+=/usr/local/go/misc/vim
colorscheme railscasts
"" ========== These come from Mislav (http://mislav.uniqpath.com/2011/12/vim-revisited/) ==========
set nocompatible " choose no compatibility with legacy vi
syntax enable
set encoding=utf-8
set showcmd " display incomplete commands
filetype plugin indent on " load file type plugins + indentation
"" Whitespace
set nowrap " don't wrap lines
set tabstop=2 shiftwidth=2 " a tab is two spaces (or set this to 4)
set expandtab " use spaces, not tabs (optional)
set backspace=indent,eol,start " backspace through everything in insert mode
"" Searching
set hlsearch " highlight matches
set incsearch " incremental searching
"" ========== NERDTree ==========
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif " close vim if NERDTree is the only open buffer
"" ========== Josh's shit ==========
set nobackup " no backup files
set nowritebackup " only in case you don't want a backup file while editing
set noswapfile " no swap files
set scrolloff=4 " adds top/bottom buffer between cursor and window
set cursorline " colours the line the cursor is on
set number " line numbers
nmap <Leader>p orequire "pry"<CR>binding.pry<ESC>; " pry insertion
vnoremap . :norm.<CR> " in visual mode, "." will for each line, go into normal mode and execute the "."
"" ========== My shit ==========
imap kj <Esc>
" easier navigation between split windows
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
" Emacs/Readline keybindings for commandline mode
" http://tiswww.case.edu/php/chet/readline/readline.html#SEC4
" many of these taken from vimacs http://www.vim.org/scripts/script.php?script_id=300
"
" navigation
cnoremap <C-a> <Home>
cnoremap <C-e> <End>
cnoremap <C-f> <Right>
cnoremap <C-b> <Left>
cnoremap <Esc>b <S-Left> " commenting out b/c makes it pause
cnoremap <Esc>f <S-Right>
cnoremap <M-b> <S-Left>
cnoremap <M-f> <S-Right>
" editing
cnoremap <M-p> <Up>
cnoremap <M-n> <Down>
cnoremap <C-k> <C-f>d$<C-c><End>
cnoremap <C-y> <C-r><C-o>"
cnoremap <C-d> <Right><C-h>