2016-04-11 00:42:09 +00:00
|
|
|
scriptencoding utf-8
|
|
|
|
set encoding=utf-8
|
2016-04-11 00:59:36 +00:00
|
|
|
|
|
|
|
" Store the current system name so that we can conditionally set configs for
|
|
|
|
" different platforms
|
|
|
|
let s:uname = system("echo -n \"$(uname)\"")
|
2016-12-12 05:00:37 +00:00
|
|
|
let s:vim_dir = $HOME . "/.vim"
|
2016-04-11 00:59:36 +00:00
|
|
|
|
|
|
|
function! IsWindows()
|
|
|
|
if s:uname =~ "mingw"
|
|
|
|
return 1
|
|
|
|
endif
|
|
|
|
return 0
|
|
|
|
endfunction
|
|
|
|
|
2012-11-16 06:05:17 +00:00
|
|
|
let mapleader=","
|
|
|
|
|
2015-02-24 04:34:00 +00:00
|
|
|
set nocompatible
|
|
|
|
filetype off
|
|
|
|
|
2012-05-19 19:56:52 +00:00
|
|
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" PLUGINS
|
|
|
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
2015-11-29 19:41:56 +00:00
|
|
|
call plug#begin('~/.vim/plugged')
|
2015-02-24 04:34:00 +00:00
|
|
|
|
2015-11-29 19:41:56 +00:00
|
|
|
Plug 'mattn/webapi-vim' " Required by gist-vim
|
|
|
|
Plug 'mattn/gist-vim'
|
|
|
|
Plug 'bling/vim-airline'
|
|
|
|
Plug 'tpope/vim-obsession'
|
|
|
|
Plug 'tpope/vim-fugitive'
|
|
|
|
Plug 'tpope/vim-classpath'
|
2016-08-03 04:31:16 +00:00
|
|
|
Plug 'tpope/vim-dispatch'
|
2016-10-23 16:47:16 +00:00
|
|
|
Plug 'craigemery/vim-autotag'
|
|
|
|
|
2015-12-27 23:30:24 +00:00
|
|
|
" DISABLED since it requires vim 7.3.598+ and I don't have that on my macbook
|
|
|
|
" Plug 'Valloric/YouCompleteMe'
|
2015-11-29 19:41:56 +00:00
|
|
|
Plug 'rking/ag.vim'
|
2015-11-29 23:25:02 +00:00
|
|
|
Plug 'scrooloose/syntastic'
|
2016-01-18 20:49:58 +00:00
|
|
|
Plug 'nelstrom/vim-qargs'
|
2015-03-24 21:55:35 +00:00
|
|
|
|
|
|
|
" Colors
|
2015-11-29 19:41:56 +00:00
|
|
|
Plug 'reedes/vim-colors-pencil'
|
|
|
|
Plug 'nanotech/jellybeans.vim'
|
|
|
|
Plug 'sickill/vim-monokai'
|
|
|
|
Plug 'elixir-lang/vim-elixir'
|
|
|
|
Plug 'chmllr/elrodeo-colorscheme'
|
|
|
|
Plug 'altercation/vim-colors-solarized'
|
2015-03-24 21:55:35 +00:00
|
|
|
|
|
|
|
" Clojure
|
2015-11-29 19:41:56 +00:00
|
|
|
Plug 'kien/rainbow_parentheses.vim'
|
|
|
|
Plug 'guns/vim-clojure-highlight'
|
|
|
|
Plug 'guns/vim-clojure-static'
|
|
|
|
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
|
|
|
|
|
|
|
|
call plug#end()
|
2015-03-24 21:55:35 +00:00
|
|
|
|
2015-03-21 19:13:17 +00:00
|
|
|
filetype plugin indent on
|
2015-02-24 04:34:00 +00:00
|
|
|
|
2012-04-19 14:23:13 +00:00
|
|
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" BASIC EDITING CONFIGURATION
|
|
|
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" allow unsaved background buffers and remember marks/undo for them
|
|
|
|
set hidden
|
|
|
|
set history=10000
|
|
|
|
set expandtab
|
2012-11-04 23:22:31 +00:00
|
|
|
set tabstop=2
|
|
|
|
set shiftwidth=2
|
|
|
|
set softtabstop=2
|
2011-04-15 18:44:28 +00:00
|
|
|
set autoindent
|
2012-04-19 14:23:13 +00:00
|
|
|
set laststatus=2
|
|
|
|
set showmatch
|
|
|
|
set incsearch
|
2013-04-20 18:00:26 +00:00
|
|
|
set dictionary+=/usr/share/dict/words
|
2015-11-29 21:24:53 +00:00
|
|
|
"set clipboard=unnamed " yank and paste with the system clipboard
|
2012-05-19 19:56:52 +00:00
|
|
|
set number
|
2012-04-19 14:23:13 +00:00
|
|
|
set hlsearch
|
|
|
|
" make searches case-sensitive only if they contain upper-case characters
|
|
|
|
set ignorecase smartcase
|
|
|
|
" highlight current line
|
|
|
|
set cmdheight=2
|
|
|
|
set switchbuf=useopen
|
|
|
|
set numberwidth=5
|
|
|
|
set showtabline=2
|
|
|
|
set winwidth=79
|
2016-04-11 00:59:36 +00:00
|
|
|
|
|
|
|
if IsWindows()
|
|
|
|
" Just assume we don't have a zsh shell
|
|
|
|
set shell=bash
|
|
|
|
else
|
|
|
|
set shell=zsh
|
|
|
|
endif
|
|
|
|
|
2012-04-19 14:23:13 +00:00
|
|
|
" Prevent Vim from clobbering the scrollback buffer. See
|
|
|
|
" http://www.shallowsky.com/linux/noaltscreen.html
|
|
|
|
set t_ti= t_te=
|
|
|
|
" keep more context when scrolling off the end of a buffer
|
|
|
|
set scrolloff=3
|
|
|
|
" Store temporary files in a central spot
|
|
|
|
set backup
|
|
|
|
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
|
|
|
|
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
|
|
|
|
" allow backspacing over everything in insert mode
|
|
|
|
set backspace=indent,eol,start
|
|
|
|
" display incomplete commands
|
|
|
|
set showcmd
|
2015-02-28 19:28:13 +00:00
|
|
|
" Spell checking autocomplete
|
|
|
|
set complete+=kspell
|
2012-04-19 14:23:13 +00:00
|
|
|
" Enable highlighting for syntax
|
2011-04-15 18:44:28 +00:00
|
|
|
syntax on
|
2012-04-19 14:23:13 +00:00
|
|
|
" Enable file type detection.
|
|
|
|
" Use the default filetype settings, so that mail gets 'tw' set to 72,
|
|
|
|
" 'cindent' is on in C files, etc.
|
|
|
|
" Also load indent files, to automatically do language-dependent indenting.
|
|
|
|
" use emacs-style tab completion when selecting files, etc
|
2013-08-30 17:11:59 +00:00
|
|
|
set wildmenu
|
|
|
|
set wildmode=longest,list,full
|
2013-04-06 17:19:30 +00:00
|
|
|
set wildignore+=*/tmp/*,*/log/*,*.so,*.swp,*.zip,*/rdoc/*
|
2012-11-28 04:23:04 +00:00
|
|
|
set colorcolumn=90
|
2013-01-28 17:58:14 +00:00
|
|
|
" Show trailing whitespace
|
2013-04-21 23:36:08 +00:00
|
|
|
set list listchars=tab:»·,trail:·
|
2013-05-08 02:34:57 +00:00
|
|
|
" Adding this since the esc remap on the 'i' key had a long delay when pressed
|
|
|
|
set timeoutlen=300 ttimeoutlen=0
|
2011-04-15 18:44:28 +00:00
|
|
|
|
2013-08-16 20:50:47 +00:00
|
|
|
" Allow undo when doing back into a closed file
|
|
|
|
set undolevels=1000
|
|
|
|
set undoreload=10000
|
2016-11-04 19:19:59 +00:00
|
|
|
" Keep undo history across sessions by storing it in a file
|
|
|
|
if has('persistent_undo')
|
|
|
|
let undo_dir = expand(s:vim_dir . '/undo')
|
|
|
|
" Create dirs
|
|
|
|
if IsWindows()
|
|
|
|
let mkdir = 'mkdir '
|
|
|
|
else
|
|
|
|
let mkdir = 'mkdir -p '
|
|
|
|
endif
|
|
|
|
:silent call system(mkdir . s:vim_dir)
|
|
|
|
:silent call system(mkdir . undo_dir)
|
|
|
|
let &undodir = undo_dir
|
|
|
|
" Persist undo
|
|
|
|
set undofile
|
|
|
|
endif
|
2013-08-16 20:50:47 +00:00
|
|
|
|
2013-07-10 16:13:13 +00:00
|
|
|
" When loading text files, wrap them and don't split up words.
|
|
|
|
au BufNewFile,BufRead *.txt setlocal wrap
|
|
|
|
au BufNewFile,BufRead *.txt setlocal lbr
|
2014-09-30 00:51:23 +00:00
|
|
|
|
2014-12-03 19:33:43 +00:00
|
|
|
" Remove trailing whitespace on save all files.
|
|
|
|
au BufWritePre * :%s/\s\+$//e
|
|
|
|
|
2013-05-01 13:48:08 +00:00
|
|
|
" Fix vim's background colour erase - http://snk.tuxfamily.org/log/vim-256color-bce.html
|
|
|
|
if &term =~ '256color'
|
|
|
|
" Disable Background Color Erase (BCE) so that color schemes
|
|
|
|
" work properly when Vim is used inside tmux and GNU screen.
|
|
|
|
" See also http://snk.tuxfamily.org/log/vim-256color-bce.html
|
|
|
|
set t_ut=
|
|
|
|
endif
|
|
|
|
|
2013-08-16 20:50:47 +00:00
|
|
|
" Disable arrow keys
|
|
|
|
map <up> <nop>
|
|
|
|
map <down> <nop>
|
|
|
|
map <left> <nop>
|
|
|
|
map <right> <nop>
|
|
|
|
imap <up> <nop>
|
|
|
|
imap <down> <nop>
|
|
|
|
imap <left> <nop>
|
|
|
|
imap <right> <nop>
|
|
|
|
|
2013-07-10 16:13:13 +00:00
|
|
|
" Notes and other helpers
|
2015-10-16 05:10:05 +00:00
|
|
|
map <leader>pn :sp ~/.personal-files/brain/writing/stack.txt<cr>
|
|
|
|
map <leader>sn :sp ~/.personal-files/documents/software-notes/clojure.md<cr>
|
2016-01-18 20:49:58 +00:00
|
|
|
map <leader>rn :sp ~/.work-files/dive-networks/files/notes/refactoring-notes.md<cr>
|
2013-07-10 16:13:13 +00:00
|
|
|
|
2016-08-03 04:31:01 +00:00
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" Run build script
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
function! RunBuildScript()
|
|
|
|
let l:existing_buf = bufwinnr("__build_output_log__")
|
|
|
|
let l:current_buf = bufnr("%")
|
|
|
|
|
|
|
|
" Save current buffer in case there are unsaved changes
|
2016-08-07 07:39:32 +00:00
|
|
|
silent! wall
|
2016-08-03 04:31:01 +00:00
|
|
|
|
|
|
|
if l:existing_buf > 0
|
2016-08-06 14:15:45 +00:00
|
|
|
silent! exe l:existing_buf . " wincmd w"
|
2016-08-03 04:31:01 +00:00
|
|
|
"execute 'botright sb' l:existing_buf
|
|
|
|
else
|
|
|
|
botright sp __build_output_log__
|
2016-08-06 14:15:45 +00:00
|
|
|
setlocal buftype=nofile
|
2016-08-03 04:31:01 +00:00
|
|
|
resize 10
|
|
|
|
endif
|
|
|
|
|
|
|
|
" Clear the buffer
|
|
|
|
normal! ggdG
|
|
|
|
|
|
|
|
" Output compile log into buffer
|
2017-02-18 15:49:44 +00:00
|
|
|
let l:output = system("./build.sh")
|
2016-08-03 04:31:01 +00:00
|
|
|
call append(0, split(l:output, '\v\n'))
|
2016-08-07 07:39:32 +00:00
|
|
|
go
|
2016-08-03 04:31:01 +00:00
|
|
|
|
2016-08-06 14:15:45 +00:00
|
|
|
silent! exe l:existing_buf. " wincmd w"
|
2016-08-03 04:31:01 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
nnoremap <leader>b :call RunBuildScript()<cr>
|
|
|
|
nnoremap <leader>bb :bw!<cr>
|
2015-03-21 19:13:17 +00:00
|
|
|
|
2014-12-03 19:33:43 +00:00
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
2015-12-06 05:14:43 +00:00
|
|
|
" Lisp
|
2014-12-03 19:33:43 +00:00
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" Rainbow parens ala rainbow_parentheses.vim
|
|
|
|
au VimEnter * RainbowParenthesesToggle
|
|
|
|
au Syntax * RainbowParenthesesLoadRound
|
|
|
|
au Syntax * RainbowParenthesesLoadSquare
|
|
|
|
au Syntax * RainbowParenthesesLoadBraces
|
2013-07-10 16:13:13 +00:00
|
|
|
|
2015-12-06 05:14:43 +00:00
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" Schemes
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" properly indent schemes (scheme, racket, etc)
|
|
|
|
autocmd bufread,bufnewfile *.lisp,*.scm,*.rkt setlocal equalprg=scmindent.rkt
|
2015-03-21 19:13:17 +00:00
|
|
|
|
2014-12-01 00:18:25 +00:00
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" COLORS
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
2016-05-24 01:36:49 +00:00
|
|
|
let s:default_bg = 'dark'
|
2016-10-23 16:47:16 +00:00
|
|
|
let s:dark_theme = 'pencil'
|
2016-05-24 01:36:49 +00:00
|
|
|
let s:light_theme = 'pencil'
|
2014-12-01 00:18:25 +00:00
|
|
|
let g:airline_theme = 'pencil'
|
|
|
|
|
2016-05-24 01:36:49 +00:00
|
|
|
if s:default_bg =~ 'light'
|
|
|
|
" The order that these are set matters for some themes
|
|
|
|
exe 'colorscheme ' . s:light_theme
|
|
|
|
set background=light
|
|
|
|
else
|
|
|
|
exe 'colorscheme ' . s:dark_theme
|
|
|
|
set background=dark
|
|
|
|
endif
|
|
|
|
|
2014-12-01 00:18:25 +00:00
|
|
|
" Switch between light and dark
|
2016-05-24 01:36:49 +00:00
|
|
|
map <leader>l :call ChangeBgTheme('dark')<cr>
|
|
|
|
map <leader>ll :call ChangeBgTheme('light')<cr>
|
|
|
|
|
|
|
|
function! ChangeBgTheme(bg)
|
|
|
|
if a:bg =~ 'light'
|
|
|
|
let s:theme = s:light_theme
|
|
|
|
else
|
|
|
|
let s:theme = s:dark_theme
|
|
|
|
endif
|
2014-12-03 19:33:43 +00:00
|
|
|
|
2016-05-24 01:36:49 +00:00
|
|
|
exe 'colorscheme ' . s:theme
|
|
|
|
exe 'set background=' . a:bg
|
2014-12-03 19:33:43 +00:00
|
|
|
" Have to run this twice to get the plugin to set the colors
|
|
|
|
exec ":RainbowParenthesesToggle"
|
|
|
|
exec ":RainbowParenthesesToggle"
|
|
|
|
endfunction
|
2014-12-01 00:18:25 +00:00
|
|
|
|
2015-03-21 19:13:17 +00:00
|
|
|
|
2012-04-19 14:23:13 +00:00
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" CUSTOM AUTOCMDS
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
augroup vimrcEx
|
|
|
|
" Clear all autocmds in the group
|
|
|
|
autocmd!
|
|
|
|
autocmd FileType text setlocal textwidth=78
|
|
|
|
" Jump to last cursor position unless it's invalid or in an event handler
|
|
|
|
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
|
2011-04-15 18:44:28 +00:00
|
|
|
|
2012-04-19 14:23:13 +00:00
|
|
|
autocmd FileType ruby,haml,eruby,yaml,html,javascript,sass,cucumber set ai sw=2 sts=2 et
|
2016-04-14 13:34:42 +00:00
|
|
|
autocmd FileType python set sw=4 sts=4 et
|
2011-04-15 18:44:28 +00:00
|
|
|
|
2012-04-19 14:23:13 +00:00
|
|
|
" Indent p tags
|
2013-07-10 16:13:13 +00:00
|
|
|
autocmd FileType html,eruby if g:html_indent_tags !~ '\\|p\>' | let g:html_indent_tags .= '\|p\|li\|dt\|dd' | endif
|
2015-02-28 19:28:13 +00:00
|
|
|
|
|
|
|
" Spell check
|
2015-03-21 19:13:17 +00:00
|
|
|
autocmd BufRead,BufNewFile *.md setlocal spell spelllang=en_us
|
2012-04-19 14:23:13 +00:00
|
|
|
augroup END
|
2011-04-15 18:44:28 +00:00
|
|
|
|
2015-03-21 19:13:17 +00:00
|
|
|
|
2012-11-04 23:22:31 +00:00
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" STATUS LINE
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
:set statusline=%<%f\ (%{&ft})\ %-4(%m%)%=%-19(%3l,%02c%03V%)
|
|
|
|
|
2016-01-18 20:49:58 +00:00
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
2016-04-14 13:34:42 +00:00
|
|
|
" HIGHLIGHT TODO, NOTE, FIXME, etc
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
2016-05-23 18:24:35 +00:00
|
|
|
augroup vimrc_bugs
|
2016-04-14 13:34:42 +00:00
|
|
|
au!
|
2016-12-12 04:53:21 +00:00
|
|
|
au Syntax * syn match MyBugs /\v<(FIXME|BUG|DEPRECATED|OPTIMIZE):/
|
2016-04-14 13:34:42 +00:00
|
|
|
\ containedin=.*Comment,vimCommentTitle
|
|
|
|
augroup END
|
2016-05-23 18:24:35 +00:00
|
|
|
hi def link MyBugs Todo
|
|
|
|
|
|
|
|
augroup vimrc_notes
|
|
|
|
au!
|
2016-10-23 16:47:16 +00:00
|
|
|
au Syntax * syn match MyNotes /\v<(IDEA|NOTE|QUESTION|WARNING|IMPORTANT):/
|
2016-05-23 18:24:35 +00:00
|
|
|
\ containedin=.*Comment,vimCommentTitle
|
|
|
|
augroup END
|
|
|
|
hi def link MyNotes WildMenu
|
2016-04-14 13:34:42 +00:00
|
|
|
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
2016-01-18 20:49:58 +00:00
|
|
|
" GIT
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
map <leader>gb :Gblame<cr>
|
|
|
|
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" SEARCHING
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
2016-08-06 14:15:45 +00:00
|
|
|
" TODO: Not sure if I still need this
|
2016-01-18 20:49:58 +00:00
|
|
|
map <leader>gs :let @/ = ""<CR>
|
|
|
|
|
|
|
|
" Replace the selected text in all files within the repo
|
|
|
|
function! GlobalReplaceIt(confirm_replacement)
|
|
|
|
if exists(':Ggrep')
|
|
|
|
" let term = @/
|
|
|
|
" if empty(term)
|
|
|
|
call inputsave()
|
2016-08-03 04:28:39 +00:00
|
|
|
let l:term = input('Enter search term: ')
|
2016-01-18 20:49:58 +00:00
|
|
|
call inputrestore()
|
|
|
|
" else
|
|
|
|
" echo '\nReplacing '.term
|
|
|
|
" endif
|
|
|
|
call inputsave()
|
2016-08-03 04:28:39 +00:00
|
|
|
let l:replacement = input('Enter replacement: ')
|
2016-01-18 20:49:58 +00:00
|
|
|
call inputrestore()
|
|
|
|
if a:confirm_replacement
|
2016-08-03 04:28:39 +00:00
|
|
|
let l:confirm_opt = 'c'
|
2016-01-18 20:49:58 +00:00
|
|
|
else
|
2016-08-03 04:28:39 +00:00
|
|
|
let l:confirm_opt = 'e'
|
2016-01-18 20:49:58 +00:00
|
|
|
endif
|
2016-08-03 04:28:39 +00:00
|
|
|
execute 'Ggrep '.l:term
|
|
|
|
execute 'Qargs | argdo %s/'.l:term.'/'.l:replacement.'/g'.l:confirm_opt.' | update'
|
2016-01-18 20:49:58 +00:00
|
|
|
else
|
|
|
|
echo "Unable to search since you're not in a git repo"
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
map <leader>gg :call GlobalReplaceIt(0)<cr>
|
|
|
|
map <leader>gr :call GlobalReplaceIt(1)<cr>
|
|
|
|
|
|
|
|
function! Search()
|
2016-08-03 04:28:39 +00:00
|
|
|
let l:term = input('Grep search term: ')
|
|
|
|
if l:term != ''
|
|
|
|
exec 'Ag "' . l:term . '"'
|
2016-01-18 20:49:58 +00:00
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
map <leader>s :call Search()<cr>
|
2015-03-21 19:13:17 +00:00
|
|
|
|
2012-04-19 14:23:13 +00:00
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" MISC KEY MAPS
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
2012-11-04 23:27:39 +00:00
|
|
|
" insert an end tag with <c-e>
|
|
|
|
imap <c-e> end
|
|
|
|
|
2014-12-01 00:18:25 +00:00
|
|
|
" insert a clojure lambda <c-l>
|
|
|
|
imap <c-l> (fn [x]<space>
|
2011-04-15 18:44:28 +00:00
|
|
|
|
2013-04-20 18:00:26 +00:00
|
|
|
" Mapping ESC in insert mode and command mode to double i
|
2014-09-30 00:51:23 +00:00
|
|
|
"imap ii <C-[>
|
|
|
|
"cmap ii <C-[>
|
2011-04-15 18:44:28 +00:00
|
|
|
|
2012-11-17 02:52:40 +00:00
|
|
|
" suspend process
|
|
|
|
nmap <leader>z <c-z>
|
2012-11-16 05:14:27 +00:00
|
|
|
|
|
|
|
" Quickly edit/reload the vimrc file
|
2013-07-10 16:13:13 +00:00
|
|
|
nmap <silent> <leader>ev :vsp $MYVIMRC<cr>
|
2012-11-16 05:14:27 +00:00
|
|
|
nmap <silent> <leader>rv :so $MYVIMRC<cr>
|
|
|
|
|
2015-10-16 05:10:05 +00:00
|
|
|
" remap saving and quiting
|
2012-11-16 05:14:27 +00:00
|
|
|
nmap <leader>w :w<cr>
|
|
|
|
nmap <leader>q :q<cr>
|
2015-10-16 05:10:05 +00:00
|
|
|
nmap <leader>qq :q!<cr>
|
2012-11-16 05:14:27 +00:00
|
|
|
nmap <leader>x :x<cr>
|
2013-08-13 15:17:54 +00:00
|
|
|
:ca Wa wa
|
|
|
|
:ca WA wa
|
2012-11-16 05:14:27 +00:00
|
|
|
:ca WQ wq
|
|
|
|
:ca Wq wq
|
|
|
|
:ca W w
|
|
|
|
:ca Q q
|
|
|
|
|
2013-07-10 16:13:13 +00:00
|
|
|
command! Q q " Bind :Q to :q
|
|
|
|
command! Qall qall
|
|
|
|
" Disable Ex mode
|
|
|
|
map Q <Nop>
|
|
|
|
|
2015-12-02 15:21:05 +00:00
|
|
|
if exists(':terminal')
|
|
|
|
" Terminal mapping
|
|
|
|
map <leader>t :terminal<cr>
|
|
|
|
tnoremap <leader>e <C-\><C-n>
|
|
|
|
tnoremap <A-h> <C-\><C-n><C-w>h
|
|
|
|
tnoremap <A-j> <C-\><C-n><C-w>j
|
|
|
|
tnoremap <A-k> <C-\><C-n><C-w>k
|
|
|
|
tnoremap <A-l> <C-\><C-n><C-w>l
|
|
|
|
nnoremap <A-h> <C-w>h
|
|
|
|
nnoremap <A-j> <C-w>j
|
|
|
|
nnoremap <A-k> <C-w>k
|
|
|
|
nnoremap <A-l> <C-w>l
|
|
|
|
endif
|
2015-11-29 23:25:02 +00:00
|
|
|
|
2012-11-16 06:05:17 +00:00
|
|
|
" Map ctrl-movement keys to window switching
|
|
|
|
map <c-k> <c-w><Up>
|
|
|
|
map <c-j> <c-w><Down>
|
|
|
|
map <c-l> <c-w><Right>
|
|
|
|
map <c-h> <c-w><Left>
|
|
|
|
|
2015-11-29 23:25:02 +00:00
|
|
|
" Make it easier to jump around the command line. The default behaviour is
|
|
|
|
" using the arrow keys with or without shift
|
|
|
|
:cnoremap <C-J> <S-Left>
|
|
|
|
:cnoremap <C-K> <S-Right>
|
2015-11-29 21:57:35 +00:00
|
|
|
|
2013-04-20 18:00:26 +00:00
|
|
|
" Window splitting - couldn't figure out how to remap <c-w>v & <c-w>n to <c-m>
|
|
|
|
" & <c-n>
|
|
|
|
map <leader>m :vsplit<cr>
|
|
|
|
map <leader>mm :split<cr>
|
|
|
|
|
2016-08-06 14:16:10 +00:00
|
|
|
" Delete a word forward and backward
|
|
|
|
map <leader>a daw
|
|
|
|
map <leader>d ciw
|
|
|
|
|
2014-02-17 07:00:21 +00:00
|
|
|
" Map paste and nonumber
|
|
|
|
map <leader>p :set paste! paste?<cr>
|
|
|
|
map <leader>o :set number! number?<cr>
|
|
|
|
|
2015-02-28 19:28:13 +00:00
|
|
|
" Spell checking
|
2016-08-06 14:16:10 +00:00
|
|
|
map <leader>j :exec &spell==&spell? "se spell! spelllang=en_us" : "se spell!"<cr>
|
2015-10-16 05:10:05 +00:00
|
|
|
map <leader>= z=
|
2015-02-28 19:28:13 +00:00
|
|
|
|
2012-04-19 14:23:13 +00:00
|
|
|
" Clear the search buffer (highlighting) when hitting return
|
2012-11-04 23:22:31 +00:00
|
|
|
function! MapCR()
|
|
|
|
nnoremap <cr> :nohlsearch<cr>
|
|
|
|
endfunction
|
|
|
|
call MapCR()
|
2012-04-19 14:23:13 +00:00
|
|
|
nnoremap <leader><leader> <c-^>
|
2011-04-15 18:44:28 +00:00
|
|
|
|
2016-08-06 14:16:10 +00:00
|
|
|
" Replace currently selected text with default register without yanking it
|
|
|
|
vnoremap p "_dP
|
|
|
|
|
2015-03-21 19:13:17 +00:00
|
|
|
|
2012-11-05 02:33:43 +00:00
|
|
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" ABBREVIATIONS
|
|
|
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
:ab teh the
|
2016-10-23 16:47:16 +00:00
|
|
|
:ab taht that
|
2014-06-25 16:41:16 +00:00
|
|
|
:ab kewyord keyword
|
2016-10-23 16:47:16 +00:00
|
|
|
:ab indentity identity
|
|
|
|
:ab indetity identity
|
2014-06-25 16:41:16 +00:00
|
|
|
|
2012-11-05 02:33:43 +00:00
|
|
|
|
2012-04-19 14:23:13 +00:00
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" MULTIPURPOSE TAB KEY
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
function! InsertTabWrapper()
|
2016-08-03 04:28:39 +00:00
|
|
|
let l:col = col('.') - 1
|
|
|
|
if !l:col || getline('.')[l:col - 1] !~ '\k'
|
2012-04-19 14:23:13 +00:00
|
|
|
return "\<tab>"
|
|
|
|
else
|
|
|
|
return "\<c-p>"
|
2011-04-15 18:44:28 +00:00
|
|
|
endif
|
2012-04-19 14:23:13 +00:00
|
|
|
endfunction
|
|
|
|
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
|
|
|
|
inoremap <s-tab> <c-n>
|
|
|
|
|
|
|
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" RENAME CURRENT FILE
|
|
|
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
function! RenameFile()
|
2016-08-03 04:28:39 +00:00
|
|
|
let l:old_name = expand('%')
|
|
|
|
let l:new_name = input('New file name: ', expand('%'), 'file')
|
|
|
|
if l:new_name != '' && l:new_name != l:old_name
|
|
|
|
exec ':saveas ' . l:new_name
|
|
|
|
exec ':silent !rm ' . l:old_name
|
2012-04-19 14:23:13 +00:00
|
|
|
redraw!
|
2011-04-15 18:44:28 +00:00
|
|
|
endif
|
2012-04-19 14:23:13 +00:00
|
|
|
endfunction
|
|
|
|
map <leader>n :call RenameFile()<cr>
|
|
|
|
|
|
|
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" PROMOTE VARIABLE TO RSPEC LET
|
|
|
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
function! PromoteToLet()
|
|
|
|
:normal! dd
|
|
|
|
" :exec '?^\s*it\>'
|
|
|
|
:normal! P
|
|
|
|
:.s/\(\w\+\) = \(.*\)$/let(:\1) { \2 }/
|
|
|
|
:normal ==
|
|
|
|
endfunction
|
|
|
|
:command! PromoteToLet :call PromoteToLet()
|
2014-05-17 19:31:36 +00:00
|
|
|
:map <leader>pl :PromoteToLet<cr>
|
2012-04-19 14:23:13 +00:00
|
|
|
|
2015-03-21 19:13:17 +00:00
|
|
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" MARKDOWN
|
|
|
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
2013-08-16 20:50:47 +00:00
|
|
|
" Use Marked.app to preview Markdown files...
|
2014-02-17 07:00:21 +00:00
|
|
|
nnoremap <leader>pp :silent !open -a Marked.app '%:p'<cr>
|
2013-08-16 20:50:47 +00:00
|
|
|
|
2015-03-21 19:13:17 +00:00
|
|
|
|
|
|
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" SELECTA -- find files with fuzzy-search
|
|
|
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" Run a given vim command on the results of fuzzy selecting from a given shell
|
|
|
|
" command. See usage below.
|
|
|
|
function! SelectaCommand(choice_command, selecta_args, vim_command)
|
|
|
|
try
|
2016-08-03 04:28:39 +00:00
|
|
|
let l:selection = system(a:choice_command . " | selecta " . a:selecta_args)
|
2015-03-21 19:13:17 +00:00
|
|
|
catch /Vim:Interrupt/
|
|
|
|
" Swallow the ^C so that the redraw below happens; otherwise there will be
|
|
|
|
" leftovers from selecta on the screen
|
|
|
|
redraw!
|
|
|
|
return
|
|
|
|
endtry
|
|
|
|
redraw!
|
2016-08-03 04:28:39 +00:00
|
|
|
exec a:vim_command . " " . l:selection
|
2015-03-21 19:13:17 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
" Find all files in all non-dot directories starting in the working directory.
|
|
|
|
" Fuzzy select one of those. Open the selected file with :e.
|
|
|
|
nnoremap <leader>f :call SelectaCommand("find * -type f ! -path 'resources/public/js/*' ! -path 'resources/.sass-cache/*' ! -path 'target/*'", "", ":e")<cr>
|
|
|
|
|
|
|
|
|
|
|
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" NERDTREE
|
|
|
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
"nmap <leader>d :NERDTreeToggle<CR>
|
|
|
|
"nmap <leader>ff :NERDTreeFind<CR>
|
|
|
|
|
|
|
|
|
|
|
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" GIST VIM
|
|
|
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
let g:gist_detect_filetype = 1
|
|
|
|
let g:gist_open_browser_after_post = 1
|
|
|
|
let g:gist_show_privates = 1
|
|
|
|
let g:gist_post_private = 1
|
|
|
|
|
|
|
|
|
|
|
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" VIM-CLOJURE-STATIC
|
|
|
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" Default
|
|
|
|
let g:clojure_fuzzy_indent = 1
|
2015-10-16 05:10:05 +00:00
|
|
|
let g:clojure_align_multiline_strings = 1
|
2015-03-21 19:13:17 +00:00
|
|
|
let g:clojure_fuzzy_indent_patterns = ['^match', '^with', '^def', '^let']
|
|
|
|
let g:clojure_fuzzy_indent_blacklist = ['-fn$', '\v^with-%(meta|out-str|loading-context)$']
|
|
|
|
|
|
|
|
|
|
|
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" C-TAGS
|
|
|
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
set tags+=tags;$HOME
|