Skip to content

Instantly share code, notes, and snippets.

@manlon
Last active September 19, 2017 00:16
Show Gist options
  • Save manlon/fa7b64e2eb46f188f55b166212051b2e to your computer and use it in GitHub Desktop.
Save manlon/fa7b64e2eb46f188f55b166212051b2e to your computer and use it in GitHub Desktop.
filetype on
filetype off
execute pathogen#infect()
syntax on
filetype plugin indent on
" ruby-friendly tab defaults
set tabstop=2
set smarttab
set shiftwidth=2
set autoindent
set smartindent " ??
set expandtab
" search options
set incsearch
" set ignorecase
" set smartcase
set scrolloff=5
autocmd BufRead,BufNewFile *.ru set filetype=ruby
autocmd FileType python set tabstop=4|set shiftwidth=4|set expandtab|set softtabstop=4
autocmd FileType javascript set tabstop=4|set shiftwidth=4|set expandtab|set softtabstop=4
set vb " visual bell
set number " Show line numbering
set ruler " line numbers and column the cursor is on
set showcmd " Display what command is waiting for an operator
set showmatch " Briefly jump to the previous matching paren
"set matchtime=2 " For .2 seconds
" home-row escape shortcut
:inoremap ;; <ESC>
" leader key
let mapleader = "\\"
:nmap <C-j> jzz
:nmap <C-k> kzz
" heresy
:inoremap <C-a> <esc>I
:inoremap <C-e> <esc>A
set wildmode=longest,list,full
set wildmenu
runtime! macros/matchit.vim
:colorscheme vividchalk
" Turn on menu bar in MacVim
:set guioptions+=T
" CtrlP options
let g:ctrlp_cmd = 'CtrlPMixed' " mixed mode (buffers too)
let g:ctrlp_match_func = {'match' : 'matcher#cmatch' } " better matcher (Command-T-like)
let g:ctrlp_prompt_mappings = {
\ 'AcceptSelection("e")': ['<c-t>'],
\ 'AcceptSelection("t")': ['<cr>', '<2-LeftMouse>'],
\ } " open in new tab by default
let g:ctrlp_custom_ignore = {
\ 'dir': 'node_modules/[^@]'
\ }
let g:ackprg = 'ag --nogroup --nocolor --column'
:nmap <leader>A :Ack
:nmap <leader>a #*:AckFromSearch<Enter>
:nmap <C-Enter> <C-w><C-]><C-w>T
:nmap <leader>\ Vgcj
:nmap <leader><space> i<space><esc>
let g:elm_format_autosave = 1

Here is how to get going with a vim setup like the one I use.

  1. Install MacVim (if you want to use vim on OSX)

https://github.com/macvim-dev/macvim/releases

MacVim is an implementation of vim for OS X which is nice b/c it integrates well will the desktop, native key bindings, etc.

  1. Install pathogen

https://github.com/tpope/vim-pathogen

Follow the instructions there. pathogen provides a sane way to manage vim plugins (the native way is insane so everyone uses this or something similar). Plugins can now be installed by cloning the plugins into ~/.vim/bundle . (Note that pathogen is not the only plugin manager available, but I like it because it is simple.)

  1. Install ctrlp ...

cd ~/.vim/bundle && git clone https://github.com/kien/ctrlp.vim.git

... and an enhanced matcher for it

cd ~/.vim/bundle && git clone https://github.com/JazzCore/ctrlp-cmatcher.git

... which requires an additional compile step (on OS X)

  export CFLAGS=-Qunused-arguments
  export CPPFLAGS=-Qunused-arguments
  cd ~/.vim/bundle/ctrlp-cmatcher/
  ./install.sh

CtrlP is a super awesome file finder extension. It's pretty life changing. It also requires a line in your .vimrc (if you don't use the one I provide below)

  1. Spiff up your ~/.vimrc . vim is configured using its own vim script language. You can configure a lot of vim's behavior.

Note I do some extra configuration for ctrlp and ack.vim plugins.

  1. Go to town installing other plugins that sound good to you -- although you might want to start slow to get the hang of vanilla vim. As mentioned installing a plugin usually means git clone the project into ~/.vim/bundle. Here are some that I use/have used, many of which come from https://github.com/tpope , who is some sort of vim god.
  1. You may want to install color schemes. There are a lot out there. I use one called vividchalk. Here is a big pack of them: https://github.com/flazz/vim-colorschemes . Drop the color scheme files into ~/.vim/colors to make them available.

  2. Learn you some vim! A classic tool to help is vimtutor (command line). Obv there are plenty of online resources. And we all love playing vim golf in the slack channel.

Enjoy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment