Skip to content

Instantly share code, notes, and snippets.

@ktravis
Created November 6, 2013 05:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ktravis/7331359 to your computer and use it in GitHub Desktop.
" basic --------------------------------------------------- {{{
" colors
set t_Co=256
syntax on
set nocompatible
set wrap " for long lines
set textwidth=80 " #
set formatoptions=qrn1 " #
set colorcolumn=+1 " #
set noswapfile
set scrolloff=3
set nu
set showmode
set showcmd
set hidden
set expandtab
set autoindent
set tabstop=4
set shiftwidth=4
set softtabstop=4
" Wildmenu ------------------------------------------------ {{{
set wildmenu
set wildmode=list:longest
set wildignore+=.hg,.git,.svn " Version control
set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
set wildignore+=*.spl " compiled spelling word
set wildignore+=*.sw? " Vim swap files
set wildignore+=*.DS_Store " OSX bullshit
set wildignore+=*.luac " Lua byte code
set wildignore+=migrations " Django migrations
set wildignore+=*.pyc " Python byte code
set wildignore+=*.orig
" }}}
set encoding=utf-8
set visualbell
set ttyfast
set ruler
set backspace=indent,eol,start
set laststatus=2
set relativenumber " relative line numbers
set undofile
" sudo hack
cmap w!! silent w !sudo tee %
" powerline
let g:Powerline_symbols = 'fancy'
set ignorecase
set smartcase
set gdefault " :%s/foo/bar/ instead of :%s/foo/bar/g
set incsearch " highlight search stuff
set showmatch " #
set hlsearch " #
set listchars=tab:▸\ ,eol:¬,extends:❯,precedes:
augroup line_return
au!
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ execute 'normal! g`"zvzz' |
\ endif
augroup end
" }}}
" Mappings ------------------------------------------------ {{{
let mapleader = ","
inoremap jj <Esc>
nnoremap ; :
" (normal regex)
nnoremap / /\v
vnoremap / /\v
" tabs match bracket pairs
nnoremap <tab> %
vnoremap <tab> %
" fix nav, disable arrows
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
nnoremap j gj
nnoremap k gk
" goddamn help key
inoremap <F1> <ESC>
nnoremap <F1> <ESC>
vnoremap <F1> <ESC>
" Space to toggle folds
nnoremap <space> za
vnoremap <space> za
" Man
nnoremap M K
" D deletes to end of line
nnoremap D d$
" Don't move on *
nnoremap * *<c-o>
" Keep search in middle of window
nnoremap n nzzzv
nnoremap N Nzzzv
" Move to end/beginning of line
nnoremap H ^
nnoremap L $
vnoremap L g_
" Move line up/down
nnoremap - ddp
nnoremap _ dd2kp
" Split line, cc for normal S
nnoremap S i<cr><esc>^mwgk:silent! s/\v +$//<cr>:noh<cr>`w
" 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
" }}}
" leader mappings ----------------------------------------- {{{
nnoremap <leader><space> :noh<cr>
" ^ turn off search highlights ^
noremap <leader><tab> :b#<cr>
nnoremap <leader>W :%s/\s\_$//<cr>:let @/=''<CR>
" ^ strip trailing whitespace globally ^
" nnoremap <leader>a :Ack
" fold html tags
nnoremap <leader>ft Vatzf
" sort CSS props
nnoremap <leader>S ?{<CR>jV/^\s*\}?$<CR>k:sort<CR>:noh<CR>
" re-hardwrap para
nnoremap <leader>q gqip
" reselect text that was just pasted
nnoremap <leader>v V`]
" edit .vimrc in a vertical split!
nnoremap <leader>ev <C-w><C-v><C-l>:e $MYVIMRC<CR>
" new vertical split, switch
nnoremap <leader>w <C-w>v<C-w>l
" Toggle line numbers
nnoremap <leader>n :setlocal number!<cr>
" Lazy substitute
nnoremap <leader>s :%s/
vnoremap <leader>s :%s/
" Toggle invis chars
nnoremap <leader>i :set list!<cr>
" }}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment