Skip to content

Instantly share code, notes, and snippets.

@samwhitehall
Created March 31, 2013 00:57
Show Gist options
  • Save samwhitehall/5279043 to your computer and use it in GitHub Desktop.
Save samwhitehall/5279043 to your computer and use it in GitHub Desktop.
set ai
set history=100
syntax on
set number
set title
set wildmenu
set wildmode=list:longest
set ignorecase
set smartcase
set encoding=utf-8
set scrolloff=3
set autoindent
set showmode
set showcmd
set hidden
set wildmenu
set wildmode=list:longest
set visualbell
set cursorline
set ttyfast
set ruler
set backspace=indent,eol,start
set laststatus=2
set relativenumber "line number column shows distance from current
set undofile "create .un files when edited to undo can be done when reopening file
" save all swap files in a single location
set backupdir=~/.vim/backup/
set directory=~/.vim/backup/
" , is easier than \ for leader
let mapleader = ","
" some niceities for searching/moving
nnoremap / /\v
vnoremap / /\v
" ^^ search using normal regex chars
set ignorecase " search all lower => case-insensitive search
set smartcase " 1+ chars upper => case-sensitive. this is good.
set gdefault " substitutions applied globally (all) on line
set incsearch
set showmatch
set hlsearch " highlight search results
nnoremap <leader><space> :noh<cr>
nnoremap <tab> %
vnoremap <tab> %
" ^^ easy to clear out search highlighting with ',<space>'
" long line handling
set wrap
set textwidth=79
set formatoptions=qrn1
set colorcolumn=85
nmap <left> <<
nmap <right> >>
" ^^ normal mode: no use of arrows, to force hjkl; left/right indent
nmap <Up> [e
nmap <Down> ]e
vmap <Up> [egv
vmap <Down> ]egv
" ^^ use up/down arrows to move line/selection up down in normal/visual
" mode
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
" ^^ insert mode: no use of arrows, to force normal mode switch
vmap <Left> <gv
vmap <Right> >gv
" move but stay selected in visual mode with left/right
nnoremap j gj
nnoremap k gk
" ^^ better working of j/k: move by screen line, not file line
" set appropriate tabbing
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
" use 'jj' in quick succession for ESC
inoremap jj <ESC>
" working with split windows
" horizontal split with ',hs', then focus
nnoremap <leader>hs <C-w>v<C-w>l
"vertical split with ',vs', then focus
nnoremap <leader>vs <C-w>s<C-w>l
"ctrl and h/j/k/l for moving between splits
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" enable filetype plugins, which my tell e.g. matchit.vim what to do
:filetype plugin on
" tagbar configuration
let g:tagbar_ctags_bin='/usr/local/bin/ctags' " proper ctags location
noremap <silent> <Leader>y :TagbarToggle
" colour scheme stuff
syntax enable
let g:solarized_termtrans = 1
colorscheme solarized
" yank text to OS X keyboard with ,Y
noremap <leader>y "*y
" preseve indentation when pasing with ,P
noremap <leader>p :set paste<CR>:put *<CR>:set nopaste<CR>
" Gist.vim
let g:gist_detect_filetype = 1
let g:gist_open_browser_after_post = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment