|
set nocompatible "don't need to keep compatibility with Vi |
|
|
|
set shell=bash "I think I need this because I'm running ZSH actually... |
|
|
|
filetype plugin indent on "enable detection, plugins and indenting in one step |
|
syntax on "Turn on syntax highlighting |
|
set synmaxcol=800 " Don't try to highlight lines longer than 800 characters. |
|
|
|
set background=dark "make vim use colors that look good on a dark background |
|
set showcmd "show incomplete cmds down the bottom |
|
"set showmode "show current mode down the bottom |
|
set showmatch "set show matching parenthesis |
|
|
|
"set noexrc " don't use the local config |
|
|
|
set virtualedit=all "allow the cursor to go in to 'invalid' places |
|
|
|
set incsearch "find the next match as we type the search |
|
set hlsearch "hilight searches by default |
|
set ignorecase "ignore case when searching |
|
set smartcase " ... unless they contain at least one capital letter |
|
|
|
set shiftwidth=2 "number of spaces to use in each autoindent step |
|
set shiftround "when at 3 spaces, and I hit > ... go to 4, not 5 |
|
set tabstop=2 "two tab spaces |
|
set softtabstop=2 "number of spaces to skip or insert when <BS>ing or <Tab>ing |
|
set expandtab "spaces instead of tabs for better cross-editor compatibility |
|
set smarttab "use shiftwidth and softtabstop to insert or delete (on <BS>) blanks |
|
"set cindent "recommended seting for automatic C-style indentation |
|
"set autoindent "automatic indentation in non-C files |
|
set nowrap "no wrapping |
|
set copyindent "copy the previous indentation on autoindenting |
|
set backspace=indent,eol,start "allow backspacing over everything in insert mode |
|
|
|
set noerrorbells "don't make noise |
|
|
|
"set cursorline "underline the current line in the file |
|
"set cursorcolumn "highlight the current column. Visible in GUI mode only. |
|
|
|
set wildmenu "make tab completion act more like bash |
|
set wildmode=list:longest "tab complete to longest common string, like bash |
|
|
|
"set mouse-=a "disable mouse automatically entering visual mode |
|
set mouse=a "Enable mouse support in the terminal VIM and activate visual mode with dragging |
|
|
|
"set wrap! "Word wrap on |
|
set bs=2 |
|
set number "Show line numbers |
|
|
|
set hidden "allow hiding buffers with unsaved changes |
|
|
|
"make the command line a little taller to hide 'press enter to viem more' text |
|
set cmdheight=2 |
|
|
|
set ttyfast " Improves screen redraw |
|
set splitbelow |
|
set splitright |
|
|
|
set backupdir=$HOME/.vim/backup// |
|
set directory=$HOME/.vim/backup// |
|
|
|
" Quckly time out on keycodes, but never time out on mappings |
|
set notimeout ttimeout ttimeoutlen=10 |
|
|
|
" New timeout settings to exit out of insert more quickly |
|
"set timeout timeoutlen=1000 ttimeoutlen=10 |
|
|
|
" Instead of failing a command because of unsaved changes, instead raise a |
|
" dialogue asking if you wish to save changed files. |
|
set confirm |
|
|
|
" Save when losing focus |
|
au FocusLost * :silent! wall |
|
|
|
" Resize splits when the window is resized |
|
au VimResized * :wincmd = |
|
|
|
let mapleader = "," "remap leader to ',' which is much easier than '\' |
|
let maplocalleader = "\\" |
|
|
|
:set guifont=Monaco\ for\ Powerline:h12 |
|
|
|
" Open NERDTree with [<leader>d] |
|
map <Leader>d :NERDTreeTabsToggle<CR> |
|
" Show current file in the NERDTree hierarchy |
|
map <Leader>D :NERDTreeFind<CR> |
|
|
|
let NERDTreeMinimalUI=1 |
|
let NERDTreeDirArrows=1 |
|
let NERDTreeWinSize = 51 |
|
let NERDTreeShowLineNumbers=1 |
|
let g:nerdtree_tabs_focus_on_files=1 |
|
let g:nerdtree_tabs_open_on_console_startup=1 |
|
|
|
|
|
" CtrlP mappings |
|
" -------------- |
|
map <C-t> :CtrlP<CR> |
|
|
|
" Exclude files from ctrl-p finder |
|
let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$' |
|
" Disable default mapping |
|
let g:ctrlp_map = '' |
|
|
|
let g:ctrlp_prompt_mappings = { |
|
\ 'AcceptSelection("h")': ['<c-x>', '<c-cr>', '<c-s>', '<c-i>'] |
|
\ } |
|
|
|
|
|
" Pasting support |
|
set pastetoggle=<F2> " Press F2 in insert mode to preserve tabs when pasting from clipboard into terminal |
|
|
|
|
|
" Ack in Project. AckG matches file names in the project, regular Ack looks inside those files |
|
map <Leader><C-t> :AckG<space> |
|
map <Leader><C-f> :Ack<space> |
|
|
|
"colorscheme vividchalk |
|
colorscheme solarized |
|
|
|
" Toggles the background from dark to light |
|
call togglebg#map("<F5>") |
|
|
|
set statusline=%F%m%r%h%w[%L][%{&ff}]%y[%p%%][%04l,%04v] |
|
" | | | | | | | | | | | |
|
" | | | | | | | | | | + current |
|
" | | | | | | | | | | column |
|
" | | | | | | | | | +-- current line |
|
" | | | | | | | | +-- current % into file |
|
" | | | | | | | +-- current syntax in |
|
" | | | | | | | square brackets |
|
" | | | | | | +-- current fileformat |
|
" | | | | | +-- number of lines |
|
" | | | | +-- preview flag in square brackets |
|
" | | | +-- help flag in square brackets |
|
" | | +-- readonly flag in square brackets |
|
" | +-- modified flag in square brackets |
|
" +-- full path to file in the buffer |
|
" } |
|
|
|
|
|
|
|
"SHOW INVISIBLES |
|
"--------------- |
|
"Shortcut to toggle `set list` which turns on and off the whitespace markers |
|
nmap <leader>il :set list!<CR> |
|
"Use the same symbols as TextMate for tabstops and EOLs |
|
set listchars=tab:▸\ ,eol:¬ |
|
|
|
"256 colors support |
|
set t_Co=256 |
|
|
|
"Right margin settings for vim 7.2 or greater |
|
if version > 702 |
|
set colorcolumn=80 |
|
endif |
|
|
|
"WINDOW SPLITS |
|
"------------- |
|
""note: this is from DAS, but it's pretty agressive... not sure I like it or not |
|
"set winwidth=84 |
|
""We have to have a winheight bigger than we want to set winminheight. But if |
|
""we set winheight to be huge before winminheight, the winminheight set will |
|
""fail. |
|
"set winheight=5 |
|
"set winminheight=5 |
|
"set winheight=999 |
|
|
|
|
|
" Better split management, kept in sync with tmux' mappings of (<prefix>| and <prefix>-) |
|
noremap <leader>- :sp<CR><C-w>j |
|
noremap <leader>\| :vsp<CR><C-w>l |
|
|
|
|
|
" Allow resizing splits with =/- for up/down and +/_ right/left (repeatable w/hold too) |
|
if bufwinnr(1) |
|
map = <C-W>+ |
|
map - <C-W>- |
|
map + <C-W>> |
|
map _ <C-W>< |
|
endif |
|
|
|
|
|
"TOGGLE RELATIVE NUMBERING |
|
"------------------------- |
|
function! g:ToggleNuMode() |
|
if(&rnu == 1) |
|
set nu |
|
else |
|
set rnu |
|
endif |
|
endfunc |
|
|
|
nnoremap <Leader>l :call g:ToggleNuMode()<CR> |
|
|
|
|
|
|
|
" Reload Google Chrome on Mac from Vim. |
|
" Adapted from: https://github.com/gcollazo/BrowserRefresh-Sublime/ |
|
function! ChromeReload() |
|
python << EOF |
|
from subprocess import call |
|
browser = """ |
|
tell application "Google Chrome" to tell the active tab of its first window |
|
reload |
|
end tell |
|
""" |
|
call(['osascript', '-e', browser]) |
|
EOF |
|
endfunction |
|
|
|
map <leader>r :w<CR>:call ChromeReload()<CR> |
|
|
|
|
|
" Indent guides turned on with <leader>ig |
|
let g:indent_guides_start_level=1 |
|
let g:indent_guides_guide_size=1 |
|
|
|
|
|
"Search and replace the word under the cursor with whatever you type in |
|
nnoremap <Leader>s :%s/\<<C-r><C-w>\>/ |
|
|
|
"Search and replace only within a given selection. This DOES NOT replace all |
|
" instances on the line that the highlight is on, which is why it's awesome. |
|
vnoremap <Leader>S :s/\%V//g<Left><Left><Left> |
|
|
|
|
|
" Allow for typing various quit cmds while accidentally capitalizing a letter |
|
command! -bar Q quit "Allow quitting using :Q |
|
command! -bar -bang Q quit<bang> "Allow quitting without saving using :Q! |
|
command! -bar QA qall "Quit all buffers |
|
command! -bar Qa qall "Quit all buffers |
|
command! -bar -bang QA qall<bang> "Allow quitting without saving using :Q! |
|
command! -bar -bang Qa qall<bang> "Allow quitting without saving using :Q! |
|
" NOTE - the above has nothing to do with the quit commands below |
|
|
|
|
|
" Make Q useful and avoid the confusing Ex mode. |
|
" Pressing Q with this mapping does nothing intentionally |
|
noremap Q <nop> |
|
|
|
" Close window. |
|
noremap QQ :q<CR> |
|
|
|
" close and write |
|
noremap WQ :wq<CR> |
|
|
|
" Close a full tab page. |
|
noremap QW :windo bd<CR> |
|
|
|
" Close all. |
|
noremap QA :qa<CR> |
|
|
|
" Close, damn you! |
|
noremap Q! :q!<CR> |
|
|
|
" Close out of all without saving (be careful ;) |
|
"nmap <leader>X :qa!<cr> |
|
|
|
"I never much liked the S command in normal mode. Substitutes the whole line after a motion. So we'll disable it here. |
|
nmap S <nop> |
|
|
|
" Session management |
|
" ----------------- |
|
" Create new session |
|
nmap SC :Obsess ~/.vim/sessions/ |
|
" Open the last saved session |
|
nmap SO :so ~/.vim/sessions/ |
|
nmap SQ :Obsess!<CR> |
|
|
|
|
|
" Save |
|
" Hit SS in insert or normal mode to save |
|
noremap SS :w<CR> |
|
inoremap SS <Esc>:w<CR> |
|
|
|
|
|
"Save the current file even if you don't have permission to do so |
|
map W!! :w !sudo tee % > /dev/null<CR> |
|
cmap w!! w !sudo tee % >/dev/null |
|
|
|
" This switches the cursor into a pipe when in insert mode tmux will only |
|
" forward escape sequences to the terminal if surrounded by a DCS sequence |
|
" http://sourceforge.net/mailarchive/forum.php?thread_name=AANLkTinkbdoZ8eNR1X2UobLTeww1jFrvfJxTMfKSq-L%2B%40mail.gmail.com&forum_name=tmux-users |
|
if exists('$TMUX') |
|
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\" |
|
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\" |
|
else |
|
let &t_SI = "\<Esc>]50;CursorShape=1\x7" |
|
let &t_EI = "\<Esc>]50;CursorShape=0\x7" |
|
endif |
|
|
|
|
|
" ExCTags window (requires http://ctags.sourceforge.net/) |
|
nmap <F8> :TagbarToggle<CR> |
|
let g:tagbar_left = 1 |
|
"autocmd FileType * nested :call tagbar#autoopen() |
|
let g:tagbar_autofocus = 1 |
|
let g:tagbar_compact = 1 |
|
let g:tagbar_autoclose = 1 |
|
|
|
|
|
" Underline the current line with '=' |
|
nmap <silent> <localleader>= :t.\|s/./=/g\|:nohls<cr> |
|
|
|
" underline the current line with '-' |
|
nmap <silent> <localleader>- :t.\|s/./-/g\|:nohls<cr> |
|
|
|
" set text wrapping toggles |
|
nmap <silent> <leader><Leader>tw :set invwrap<CR>:set wrap?<CR> |
|
|
|
" find merge conflict markers |
|
nmap <silent> <leader>fc <ESC>/\v^[<=>]{7}( .*\|$)<CR> |
|
|
|
" Adjust viewports to the same size |
|
map <Leader>= <C-w>= |
|
|
|
" Default searches to 'very magic', more like the world outside Vim. |
|
" Very magic mode and other seraching info: http://vimcasts.org/episodes/refining-search-patterns-with-the-command-line-window/ |
|
" Forward search |
|
nnoremap / /\v |
|
" Backwards search |
|
nnoremap ? ?\v |
|
vnoremap ? ?\v |
|
|
|
" Move by visual screen lines instead of file lines. (aka when navigating wrapped text) |
|
" http://vim.wikia.com/wiki/Moving_by_screen_lines_instead_of_file_lines |
|
noremap [A gk |
|
noremap [B gj |
|
noremap k gk |
|
noremap j gj |
|
inoremap [B <C-o>gj |
|
inoremap [A <C-o>gk |
|
|
|
|
|
" Tab/shift-tab to indent/outdent in visual mode. |
|
vnoremap <Tab> >gv |
|
vnoremap <S-Tab> <gv |
|
" Keep selection when indenting/outdenting. |
|
vnoremap > >gv |
|
vnoremap < <gv |
|
|
|
|
|
"NOTES ON ARROW KEYS |
|
"http://od-eon.com/blogs/liviu/macos-vim-controlarrow-functionality/ |
|
"arrow keys, up=A, down=B, right=C and left=D |
|
"<C-Up> == <Esc>[A |
|
"END NOTES |
|
|
|
|
|
|
|
" TABS |
|
" ---- |
|
function! MoveCurrentTab(value) |
|
if a:value == 0 |
|
return |
|
endif |
|
let move = a:value - 1 |
|
let move_to = tabpagenr() + move |
|
if move_to < 0 |
|
let move_to = 0 |
|
endif |
|
exe 'tabmove '.move_to |
|
endfunction |
|
|
|
" switch tab order with Ctrl+<left>/<right> |
|
map <Esc>[C :call MoveCurrentTab(1)<Esc> |
|
map <Esc>[D :call MoveCurrentTab(-1)<Esc> |
|
|
|
" previous tab(F11), next tab (F12) |
|
nmap <F11> :tabp<CR> |
|
nmap <F12> :tabn<CR> |
|
|
|
|
|
|
|
function! MoveToPrevTab() |
|
"there is only one window |
|
if tabpagenr('$') == 1 && winnr('$') == 1 |
|
return |
|
endif |
|
"preparing new window |
|
let l:tab_nr = tabpagenr('$') |
|
let l:cur_buf = bufnr('%') |
|
if tabpagenr() != 1 |
|
close! |
|
if l:tab_nr == tabpagenr('$') |
|
tabprev |
|
endif |
|
sp |
|
else |
|
close! |
|
exe "0tabnew" |
|
endif |
|
"opening current buffer in new window |
|
exe "b".l:cur_buf |
|
endfunc |
|
|
|
function! MoveToNextTab() |
|
"there is only one window |
|
if tabpagenr('$') == 1 && winnr('$') == 1 |
|
return |
|
endif |
|
"preparing new window |
|
let l:tab_nr = tabpagenr('$') |
|
let l:cur_buf = bufnr('%') |
|
if tabpagenr() < tab_nr |
|
close! |
|
if l:tab_nr == tabpagenr('$') |
|
tabnext |
|
endif |
|
sp |
|
else |
|
close! |
|
tabnew |
|
endif |
|
"opening current buffer in new window |
|
exe "b".l:cur_buf |
|
endfunc |
|
|
|
map <Esc>[B :call MoveToNextTab()<CR> |
|
map <Esc>[A :call MoveToPrevTab()<CR> |
|
|
|
|
|
|
|
|
|
" toggle hide numbers |
|
map <leader>1 :set nonumber! number?<CR> |
|
|
|
|
|
" This allows you to share Vim's clipboard with OS X. |
|
set clipboard=unnamed |
|
|
|
" Yank to OS X pasteboard. (Need to have this installed and configured per the |
|
" tmux book by Brian Hogan |
|
" https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard.git) |
|
" Only need this if clipboard=unnamed isn't enabled |
|
"noremap <leader>y "*y |
|
|
|
|
|
" Do some alignment |
|
vmap <leader>a= :Tabularize /=<CR> |
|
vmap <leader>a> :Tabularize /=><CR> |
|
vmap <leader>a: :Tabularize /:\zs<CR> |
|
nmap <leader>a, :Tabularize /,<CR> |
|
|
|
" Triggers align of cucumber tables when you close it out with a | and have at |
|
" least two lines. Thanks tpope :) |
|
function! s:align() |
|
let p = '^\s*|\s.*\s|\s*$' |
|
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p) |
|
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g')) |
|
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*')) |
|
Tabularize/|/l1 |
|
normal! 0 |
|
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.')) |
|
endif |
|
endfunction |
|
|
|
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a |
|
|
|
|
|
"folding settings |
|
" --------------- |
|
"" toggle folding with za. |
|
"" fold everything with zM |
|
"" unfold everything with zR. |
|
"" zm and zr can be used too |
|
"set foldmethod=syntax "fold based on syntax (except for haml below) |
|
"set foldnestmax=10 "deepest fold is 10 levels |
|
"set nofoldenable "dont fold by default |
|
"autocmd BufNewFile,BufRead *.haml setl foldmethod=indent nofoldenable |
|
|
|
"" Space to toggle folds. |
|
"nnoremap <Space> za |
|
"vnoremap <Space> za |
|
|
|
"" Make zO recursively open whatever top level fold we're in, no matter where the |
|
"" cursor happens to be. |
|
"nnoremap zO zCzO |
|
|
|
|
|
" Buffrgator settings |
|
let g:buffergator_viewport_split_policy="B" |
|
let g:buffergator_split_size=10 |
|
let g:buffergator_suppress_keymaps=1 |
|
let g:buffergator_sort_regime = "mru" |
|
map <Leader>b :BuffergatorToggle<cr> |
|
|
|
" go to the 80th column |
|
noremap <leader>8 80\| |
|
|
|
" commands from insert mode |
|
inoremap II <Esc>I |
|
inoremap AA <Esc>A |
|
|
|
" Pull up the TODO And NOTE and FIXME definitions from the whole app |
|
let g:TagmaTasksHeight = 10 |
|
map <Leader><Leader>tt :TagmaTasks * app/** config/** db/** doc/** features/** lib/** public/** spec/** test/** vendor/**<CR> |
|
|
|
let g:TagmaTasksPrefix = '<localleader>t' |
|
|
|
" VIMUX CONFIG |
|
"============= |
|
let VimuxHeight = "33" "this is percentage |
|
let VimuxOrientation = "h" |
|
let VimuxUseNearestPane = 1 |
|
" Inspect runner pane |
|
map <Leader>vv :InspectVimTmuxRunner<CR> |
|
" Close vim tmux runner opened by RunVimTmuxCommand |
|
map <Leader>vq :CloseVimTmuxRunner<CR> |
|
" If text is selected, save it in the v buffer and send that buffer it to tmux |
|
vmap <Leader>vs "vy :call RunVimTmuxCommand(@v . "\n", 0)<CR> |
|
" Select current paragraph and send it to tmux |
|
nmap <Leader>vs vip<LocalLeader>vs<CR> |
|
" Open vimux split with zflow support |
|
map <Leader>vo :call RunVimTmuxCommand("zflow.native")<CR> |
|
|
|
|
|
" For running minispec tests of a whole file (sort of focused...) |
|
map <leader>m :call RunVimTmuxCommand('bundle exec ruby -Itest ' . @%,1)<CR> |
|
|
|
" Set super tab to start completion with ctrl+j and move down the list with |
|
" more j's, move back with ctrl+k |
|
let g:SuperTabMappingForward = '<c-k>' |
|
let g:SuperTabMappingBackward = '<c-j>' |
|
|
|
" Toggle spellcheck with F6 (highlighted and underlined in stark WHITE) |
|
" ----------------- |
|
" z= - view spelling suggestions for a misspelled word |
|
" zg - add word to dictionary |
|
" zug - undo add word to dict |
|
hi SpellBad cterm=underline ctermfg=white |
|
nn <F6> :setlocal spell! spell?<CR> |
|
|
|
|
|
" YankRing plugin to manage yanked/deleted buffers |
|
nnoremap <silent> <F7> :YRShow<CR> |
|
|
|
" Scratch plugin for a little temp buffer that will be discarded when |
|
map <leader><tab> :Sscratch <CR> |
|
|
|
" STOP the help from being so... HELPFULL ;) |
|
inoremap <F1> <ESC> |
|
nnoremap <F1> <ESC> |
|
vnoremap <F1> <ESC> |
|
|
|
" Exit out of insert with jj |
|
inoremap jj <ESC> |
|
|
|
" Dig through the tree of undo possibilities for your current file |
|
nnoremap <F3> :GundoToggle<CR> |
|
let g:gundo_right = 1 |
|
let g:gundo_preview_bottom=1 |
|
let g:gundo_preview_height = 40 |
|
|
|
" Disable some built in commands I don't like |
|
map K <Nop> |
|
|
|
" Ensures color scheme works for the gutter diff indicators |
|
highlight clear SignColumn |
|
|
|
|
|
|
|
" Load up the vimrc_main file (this file) in vim to edit it |
|
nnoremap <Leader>ev :tabnew ~/.vimrc_main<CR> |
|
|
|
" Automatically source this file after it's saved |
|
autocmd! bufwritepost .vimrc_main source ~/.vimrc |
|
|
|
|
|
"From Gary Bernhardt |
|
function! ShowRoutes() |
|
" Requires 'scratch' plugin |
|
:topleft 100 :split __Routes__ |
|
" Make sure Vim doesn't write __Routes__ as a file |
|
:set buftype=nofile |
|
" Delete everything |
|
:normal 1GdG |
|
" Put routes output in buffer |
|
:0r! rake -s routes |
|
" Size window to number of lines (1 plus rake output length) |
|
:exec ":normal " . line("$") . "_ " |
|
" Move cursor to bottom |
|
:normal 1GG |
|
" Delete empty trailing line |
|
:normal dd |
|
endfunction |
|
map <leader>gR :call ShowRoutes()<cr> |
|
|
|
map <leader>gr :topleft :split config/routes.rb<cr> |
|
map <leader>gg :topleft 100 :split Gemfile<cr> |
|
|
|
|
|
" From Mislav - Tmux Vim Select Pane |
|
let g:tmux_is_last_pane = 0 |
|
au WinEnter * let g:tmux_is_last_pane = 0 |
|
|
|
" Like `wincmd` but also change tmux panes instead of vim windows when needed. |
|
function! TmuxWinCmd(direction) |
|
let nr = winnr() |
|
let tmux_last_pane = (a:direction == 'p' && g:tmux_is_last_pane) |
|
if !tmux_last_pane |
|
" try to switch windows within vim |
|
exec 'wincmd ' . a:direction |
|
endif |
|
" Forward the switch panes command to tmux if: |
|
" a) we're toggling between the last tmux pane; |
|
" b) we tried switching windows in vim but it didn't have effect. |
|
if tmux_last_pane || nr == winnr() |
|
let cmd = 'tmux select-pane -' . tr(a:direction, 'phjkl', 'lLDUR') |
|
exec 'silent !'.cmd |
|
redraw! " because `exec` fucked up the screen. why is this needed?? arrghh |
|
let g:tmux_is_last_pane = 1 |
|
echo cmd |
|
else |
|
let g:tmux_is_last_pane = 0 |
|
endif |
|
endfunction |
|
|
|
|
|
" navigate between split windows/tmux panes |
|
nmap <c-j> :call TmuxWinCmd('j')<cr> |
|
nmap <c-k> :call TmuxWinCmd('k')<cr> |
|
nmap <c-h> :call TmuxWinCmd('h')<cr> |
|
nmap <c-l> :call TmuxWinCmd('l')<cr> |
|
"nmap <c-\> :call TmuxWinCmd('p')<cr> |
|
|
|
|
|
" Highlight Word |
|
" |
|
" This mini-plugin provides a few mappings for highlighting words temporarily. |
|
" |
|
" Sometimes you're looking at a hairy piece of code and would like a certain |
|
" word or two to stand out temporarily. You can search for it, but that only |
|
" gives you one color of highlighting. Now you can use <leader>N where N is |
|
" a number from 1-6 to highlight the current word in a specific color. |
|
function! HiInterestingWord(n) " |
|
" Save our location. |
|
normal! mz |
|
|
|
" Yank the current word into the z register. |
|
normal! "zyiw |
|
|
|
" Calculate an arbitrary match ID. Hopefully nothing else is using it. |
|
let mid = 86750 + a:n |
|
|
|
" Clear existing matches, but don't worry if they don't exist. |
|
silent! call matchdelete(mid) |
|
|
|
" Construct a literal pattern that has to match at boundaries. |
|
let pat = '\V\<' . escape(@z, '\') . '\>' |
|
|
|
" Actually match the words. |
|
call matchadd("InterestingWord" . a:n, pat, 1, mid) |
|
|
|
" Move back to our original location. |
|
normal! `z |
|
endfunction " }}} |
|
|
|
" Mappings |
|
nnoremap <silent> <localleader>1 :call HiInterestingWord(1)<cr> |
|
nnoremap <silent> <localleader>2 :call HiInterestingWord(2)<cr> |
|
nnoremap <silent> <localleader>3 :call HiInterestingWord(3)<cr> |
|
nnoremap <silent> <localleader>4 :call HiInterestingWord(4)<cr> |
|
nnoremap <silent> <localleader>5 :call HiInterestingWord(5)<cr> |
|
nnoremap <silent> <localleader>6 :call HiInterestingWord(6)<cr> |
|
|
|
" }}} |
|
" Default Highlights |
|
hi def InterestingWord1 guifg=#000000 ctermfg=16 guibg=#ffa724 ctermbg=214 |
|
hi def InterestingWord2 guifg=#000000 ctermfg=16 guibg=#aeee00 ctermbg=154 |
|
hi def InterestingWord3 guifg=#000000 ctermfg=16 guibg=#8cffba ctermbg=121 |
|
hi def InterestingWord4 guifg=#000000 ctermfg=16 guibg=#b88853 ctermbg=137 |
|
hi def InterestingWord5 guifg=#000000 ctermfg=16 guibg=#ff9eb8 ctermbg=211 |
|
hi def InterestingWord6 guifg=#000000 ctermfg=16 guibg=#ff2c4b ctermbg=195 |
|
|
|
|
|
"SEARCH OPTIONS |
|
"-------------- |
|
" turn highlighting off after a search (and / or turn off highlights) |
|
noremap <silent> <leader><space> :noh<cr>:call clearmatches()<cr> |
|
|
|
|
|
" Toggle "keep current line in the center of the screen" mode |
|
nnoremap <leader>C :let &scrolloff=999-&scrolloff<cr> |
|
|
|
|
|
|
|
" Jumping to tags. |
|
" |
|
" Basically, <c-]> jumps to tags (like normal) and <c-\> opens the tag in a new |
|
" split instead. |
|
" |
|
" Both of them will align the destination line to the upper middle part of the |
|
" screen. Both will pulse the cursor line so you can see where the hell you |
|
" are. <c-\> will also fold everything in the buffer and then unfold just |
|
" enough for you to see the destination line. |
|
nnoremap <c-]> <c-]>mzzvzz15<c-e>`z:Pulse<cr> |
|
nnoremap <c-\> <c-w>v<c-]>mzzMzvzz15<c-e>`z:Pulse<cr> |
|
|
|
" Keep search matches in the middle of the window. |
|
nnoremap n nzzzv |
|
nnoremap N Nzzzv |
|
|
|
" Same when jumping around |
|
nnoremap g; g;zz |
|
nnoremap g, g,zz |
|
nnoremap <c-o> <c-o>zz |
|
|
|
|
|
" Easy filetype switching (good for commenting code in haml filters) |
|
nnoremap _md :set ft=markdown<CR> |
|
nnoremap _hm :set ft=haml<CR> |
|
nnoremap _js :set ft=javascript<CR> |
|
nnoremap _d :set ft=diff<CR> |
|
|
|
|
|
" Send visual selection to gist.github.com as a private, filetyped Gist |
|
" Requires the gist command line too (brew install gist) |
|
"vnoremap <leader>G :w !gist -p -t %:e \| pbcopy<cr> |
|
vnoremap <leader>G :w !gist -p -t % \| pbcopy<cr> |
|
vnoremap <leader>UG :w !gist -p \| pbcopy<cr> |
|
|
|
" Keep the cursor in place while joining lines |
|
nnoremap J mzJ`z |
|
|
|
|
|
" Make sure Vim returns to the same line when you reopen a file. |
|
augroup line_return |
|
au! |
|
au BufReadPost * |
|
\ if line("'\"") > 0 && line("'\"") <= line("$") | |
|
\ execute 'normal! g`"zvzz' | |
|
\ endif |
|
augroup END |
|
|
|
|
|
" <m-j> and <m-k> to drag lines in any mode (m is alt/option) |
|
" this is the textmate move lines around thing that I used to do do with arrow |
|
" keys but less fragile because it works in tmux or not |
|
noremap ∆ :m+<CR> |
|
noremap ˚ :m-2<CR> |
|
inoremap ∆ <Esc>:m+<CR> |
|
inoremap ˚ <Esc>:m-2<CR> |
|
vnoremap ∆ :m'>+<CR>gv |
|
vnoremap ˚ :m-2<CR>gv |
|
|
|
|
|
" Don't move on * (then you press n to go to the next one) |
|
" the IndexedSearch plugin breaks this capability unfortunately |
|
nnoremap * *<c-o> |
|
|
|
|
|
augroup ft_markdown |
|
au! |
|
|
|
au BufNewFile,BufRead *.m*down setlocal filetype=markdown foldlevel=1 |
|
|
|
" Use <localleader>1/2/3 to add headings. |
|
au Filetype markdown nnoremap <buffer> <localleader>1 mzI# <ESC> |
|
au Filetype markdown nnoremap <buffer> <localleader>2 mzI## <ESC> |
|
au Filetype markdown nnoremap <buffer> <localleader>3 mzI### <ESC> |
|
augroup END |
|
|
|
|
|
" Fugitive |
|
nnoremap <leader>gd :Gdiff<cr> |
|
nnoremap <leader>gs :Gstatus<cr> |
|
nnoremap <leader>gw :Gwrite<cr> |
|
nnoremap <leader>ga :Gadd<cr> |
|
nnoremap <leader>gb :Gblame<cr> |
|
nnoremap <leader>gco :Gcheckout<cr> |
|
nnoremap <leader>gci :Gcommit<cr> |
|
nnoremap <leader>gm :Gmove<cr> |
|
nnoremap <leader>gr :Gremove<cr> |
|
|
|
|
|
|
|
" Numbers |
|
|
|
" Motion for numbers. Great for CSS. Lets you do things like this: |
|
" |
|
" margin-top: 200px; -> ciN -> margin-top: px; |
|
" ^ ^ |
|
" TODO: Handle floats. |
|
|
|
onoremap N :<c-u>call <SID>NumberTextObject(0)<cr> |
|
xnoremap N :<c-u>call <SID>NumberTextObject(0)<cr> |
|
onoremap aN :<c-u>call <SID>NumberTextObject(1)<cr> |
|
xnoremap aN :<c-u>call <SID>NumberTextObject(1)<cr> |
|
onoremap iN :<c-u>call <SID>NumberTextObject(1)<cr> |
|
xnoremap iN :<c-u>call <SID>NumberTextObject(1)<cr> |
|
|
|
function! s:NumberTextObject(whole) |
|
normal! v |
|
|
|
while getline('.')[col('.')] =~# '\v[0-9]' |
|
normal! l |
|
endwhile |
|
|
|
if a:whole |
|
normal! o |
|
|
|
while col('.') > 1 && getline('.')[col('.') - 2] =~# '\v[0-9]' |
|
normal! h |
|
endwhile |
|
endif |
|
endfunction |
|
|
|
|
|
|
|
" Pulse Line |
|
function! s:Pulse() " |
|
let current_window = winnr() |
|
windo set nocursorline |
|
execute current_window . 'wincmd w' |
|
setlocal cursorline |
|
|
|
redir => old_hi |
|
silent execute 'hi CursorLine' |
|
redir END |
|
let old_hi = split(old_hi, '\n')[0] |
|
let old_hi = substitute(old_hi, 'xxx', '', '') |
|
|
|
let steps = 9 |
|
let width = 1 |
|
let start = width |
|
let end = steps * width |
|
let color = 233 |
|
|
|
for i in range(start, end, width) |
|
execute "hi CursorLine ctermbg=" . (color + i) |
|
redraw |
|
sleep 6m |
|
endfor |
|
for i in range(end, start, -1 * width) |
|
execute "hi CursorLine ctermbg=" . (color + i) |
|
redraw |
|
sleep 6m |
|
endfor |
|
|
|
execute 'hi ' . old_hi |
|
endfunction " }}} |
|
command! -nargs=0 Pulse call s:Pulse() |
|
|
|
set encoding=utf-8 |
|
|
|
set rtp+=~/.vim/bundles/powerline/powerline/bindings/vim |
|
let g:powerline_config_overrides={"ext": {"vim": {"colorscheme": "solarized"}}} |
|
|
|
|
|
|
|
let g:InteractiveReplace_map = 'X' |
|
|
|
"let g:signify_sign_color_guibg = '#032b36' |
|
let g:signify_sign_color_inherit_from_linenr = 1 |
|
let g:signify_sign_weight = 'NONE' |
|
|
|
|
|
set formatoptions=1 |
|
set linebreak |
|
set breakat=\ ^I!@*-+;:,./?\(\[\{ |