dgy
/
hexagons
Archived
1
0
Fork 0
This repository has been archived on 2021-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
hexagons/.config/nvim/init.vim

641 lines
20 KiB
VimL
Raw Normal View History

2017-12-28 13:49:45 +00:00
" Important stuff {{{
scriptencoding utf-8 " Set utf-8 as default script encoding
let g:loaded_python_provider=1 " Disable python 2 interface
let g:python_host_skip_check=1 " Skip python 2 host check
let g:python3_host_prog = '/usr/bin/python3'
let g:tagbar_ctags_bin = '/usr/bin/ctags'
set inccommand=nosplit " Live preview of substitutes and other similar commands
let python_highlight_all=1
" Plug updates itself automatically
if empty(glob('~/.config/nvim/autoload/plug.vim'))
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
if executable('rg')
set grepprg=rg\ --vimgrep\ --no-heading
elseif executable('ag')
set grepprg=ag\ --nogroup\ --nocolor
endif
2017-12-28 13:49:45 +00:00
" }}}
" Plugins {{{
call plug#begin('~/.config/nvim/plugged')
Plug 'junegunn/vim-plug'
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'jiangmiao/auto-pairs'
Plug 'zchee/deoplete-jedi'
Plug 'w0rp/ale', { 'for': ['python', 'bash', 'dash', 'zsh'] }
Plug 'sbdchd/neoformat'
Plug 'scrooloose/nerdtree', { 'on': ['NERDTreeFind', 'NERDTreeToggle'] }
Plug 'christoomey/vim-tmux-navigator'
Plug 'lervag/vimtex', { 'for': ['tex'] }
Plug 'plasticboy/vim-markdown', { 'for': ['markdown'] }
2018-07-21 04:46:57 +00:00
Plug 'zefei/vim-wintabs'
2018-08-18 16:39:24 +00:00
Plug 'junegunn/goyo.vim', { 'on': 'Goyo' }
Plug 'chrisbra/vim-diff-enhanced'
Plug '/usr/bin/fzf'
Plug 'junegunn/fzf.vim'
2018-08-18 16:39:24 +00:00
Plug 'coddingtonbear/neomake-platformio', { 'do': ':UpdateRemotePlugins' }
Plug 'jalvesaq/vimcmdline'
Plug 'supercollider/scvim'
call plug#end()
let g:plug_window = 'rightbelow topleft new'
2017-12-28 13:49:45 +00:00
" }}}
" Options {{{
" Search down int subfolders
" Provides tab-completion for all file-related tasks
" - :b lets you autocomplete any open buffer
set path+=**
"set guicursor=n-i-ve:hor,v-r:block,a:blinkon0
set binary
2018-07-21 04:46:57 +00:00
set clipboard^=unnamedplus " system clipboard (requires +clipboard)
set encoding=utf-8 " The encoding displayed.
set fileencoding=utf-8 " The encoding written to file.
let mapleader="\<SPACE>"
let localleader=","
set shell=/bin/zsh " Setting shell to zsh
set number " Line numbers on
set showmode " Always show mode
set mousemodel=popup
set breakindent
set textwidth=120 " Text width is 120 characters
set cmdheight=1 " Command line height
set cmdwinheight=5 " Command-line lines
set pumheight=10 " Completion window max size
set helpheight=12 " Minimum help window height
set previewheight=12 " Completion preview height
set noswapfile " New buffers will be loaded without creating a swapfile
set hidden " Enables to switch between unsaved buffers and keep undo history
set lazyredraw " Don't redraw while executing macros (better performance)
set showmatch " Show matching brackets when text indicator is over them
set matchtime=2 " How many tenths of a second to blink when matching brackets
set nojoinspaces " No extra space when joining a line which ends with . ? !
set updatetime=1000 " Update time used to create swap file or other things
set synmaxcol=220 " Don't try to syntax highlight minified files
set splitbelow " Splitting a window will put the new window below the current
set splitright " Splitting a window will put the new window right of the current
set notimeout " Time out on key codes but not mappings.
set ttimeout
set ttimeoutlen=10
set ignorecase " Ignore case by default
set smartcase " Make search case sensitive only if it contains uppercase letters
set wrapscan " Search again from top when reached the bottom
set cursorline " Hightlight the screen line of the cursor
set numberwidth=5 " Minimal number of columns to use for line numbers
set nobackup
set nowritebackup
set wrap " Wrap lines longer than the width of the window
set visualbell " Use visual bell instead of beeping
set selectmode=key
set keymodel=startsel
set foldenable " Fold by default
set foldlevelstart=10
set foldnestmax=10 " Deepest fold is 10 levels
set foldmethod=marker " Markers are used to specify folds.
set completeopt-=preview " Don't show preview scratch buffers
set noexpandtab " Do not turn tabs into spaces
set tabstop=4 " Number of spaces a <Tab> equals
set softtabstop=4
set shiftwidth=4 " Number of spaces for each (auto)indent step
set foldclose=all
set nostartofline
set nosmartindent
set laststatus=1 " Status line on 2 or more files
set nosmarttab
set modeline
set modelines=2
set scrolloff=7 " Keep this many lines padding when scrolling
2018-07-21 04:46:57 +00:00
set title
set undofile
set undolevels=1000
set undoreload=10000
set undodir=$HOME/.config/nvim/undo
set nrformats-=octal
set pastetoggle=<F12>
set shortmess=aoOtIWcFs " Shorten messages and don't show intro
set omnifunc=syntaxcomplete#Complete
set complete+=]
set completeopt-=preview
set completeopt+=noinsert,longest,noselect,menuone
set formatoptions+=n
2018-05-26 20:06:45 +00:00
let formatlistpat='^\s*\(\d\+[\]:.)}\t ]\|[*-][\t ]\)\s*'
set matchpairs=(:),{:},[:],<:>
" Display all matching files when we tab complete
set wildmenu
set wildignorecase
set wildoptions=tagfile
set wildignore+=.git,.hg,.svn
set wildignore+=*.aux,*.out,*.toc
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest,*.rbc,*.class
set wildignore+=*.ai,*.bmp,*.gif,*.ico,*.jpg,*.jpeg,*.png,*.psd,*.webp
set wildignore+=*.avi,*.divx,*.mp4,*.webm,*.mov,*.m2ts,*.mkv,*.vob,*.mpg,*.mpeg
set wildignore+=*.mp3,*.oga,*.ogg,*.wav,*.flac
set wildignore+=*.eot,*.otf,*.ttf,*.woff
set wildignore+=*.doc,*.pdf,*.cbr,*.cbz
set wildignore+=*.zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz,*.kgb
set wildignore+=*.swp,.lock,.DS_Store,._*
set wildignore+=.stversions,*.pyc,*.spl,*.o,*.out,*~,%*
set wildignore+=*vim/backups*
set wildignore+=tmp/**
set wildignore+=*.gem
set wildignore+=log/**
set wildignore+=*cache*
set wildignore+=*logs*
set wildignore+=*node_modules/**
set wildignore+=__pycache__,*.egg-info
set wildmode=longest:list,full
match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
" use ripgrep as grepprg
if executable('rg')
set grepprg=rg\ --vimgrep\ --hidden\ --no-ignore-vcs
set grepformat=%f:%l:%c:%m,%f:%l:%m
endif
colorscheme turtles
highlight MatchParen cterm=bold ctermbg=none ctermfg=9
highlight TermCursor ctermfg=green guifg=green
highlight DiffAdd ctermbg=2
highlight DiffDelete ctermbg=1
highlight DiffChange ctermbg=238
highlight DiffChange ctermbg=242
" }}}
" Statusline {{{
function! GitBranch()
return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'")
endfunction
function! StatuslineGit()
let l:branchname = GitBranch()
return strlen(l:branchname) > 0?' '.l:branchname.' ':''
endfunction
function! PasteForStatusline()
let paste_status = &paste
if paste_status == 1
return " [paste] "
else
return ""
endif
endfunction
function! LinterStatus() abort
let l:counts = ale#statusline#Count(bufnr(''))
let l:all_errors = l:counts.error + l:counts.style_error
let l:all_non_errors = l:counts.total - l:all_errors
return l:counts.total == 0 ? 'OK' : printf(
\ '%dW %dE',
\ all_non_errors,
\ all_errors
\)
endfunction
set statusline=
2018-07-21 04:46:57 +00:00
set statusline+=%#Keyword#
set statusline+=%{winnr()}
set statusline+=%#SpecialKey#
set statusline+=\ %{StatuslineGit()}
set statusline+=%#CursorLineNr#
2018-07-21 04:46:57 +00:00
set statusline+=\ %{LinterStatus()}
set statusline+=\ %{PasteForStatusline()}
set statusline+=\ %h%r%w%q
set statusline+=%=
set statusline+=\ %{&fileencoding?&fileencoding:&encoding}
set statusline+=\ [%{&fileformat}\]
set statusline+=\ %l:%c\ (%p%%)
set statusline+=
" }}}
2018-02-04 16:14:51 +00:00
" AutoCommands {{{
if !exists("autocommands_loaded") && has("autocmd")
let autocommands_loaded = 1
autocmd BufWritePre * :%s/\s\+$//e " Auto remove all trailing whitespace on :w
":au FocusLost * :wa " Autosave files when focus is lost
" Disables automatic commenting on newline
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
autocmd BufWinEnter,WinEnter term://* startinsert
autocmd BufLeave term://* stopinsert
" Automatic syntax highlighting for files
aug set_file_types
au BufRead,BufNewFile *.txt set filetype=markdown
au BufRead,BufNewFile *.md set filetype=markdown
au BufRead,BufNewFile *.conf set filetype=dosini
au BufRead,BufNewFile *.bash* set filetype=sh
aug END
aug mutt_settings
autocmd BufRead,BufNewFile /tmp/neomutt* let g:goyo_width=80
autocmd BufRead,BufNewFile /tmp/neomutt* :Goyo
autocmd BufEnter /tmp/neomutt* :exe "normal! 9j\<cr>o"
autocmd BufEnter /tmp/neomutt* setl spelllang=es
aug END
endif
" }}}
2018-02-04 16:14:51 +00:00
" Read-Only files {{{
if &readonly
set laststatus=0
set ruler
set cmdheight=1
set nonumber
set noshowmode
set colorcolumn=0
endif
2017-12-28 13:49:45 +00:00
" }}}
" Tweaks for browsing {{{
" - :edit a folder to open a file browser
" - <CR>/v/t to open in an h-split/v-split/tab
let g:netrw_banner=0 " disable annoying banner
let g:netrw_browse_split=4 " open in prior window
let g:netrw_altv=1 " open splits to the right
let g:netrw_liststyle=3 " tree view
let g:netrw_list_hide=netrw_gitignore#Hide()
let g:netrw_list_hide.=',\(^\|\s\s\)\zs\.\S\+'
let g:netrw_winsize=25
2017-12-28 13:49:45 +00:00
" }}}
" {{{ Ale
let g:ale_set_highlights = 0
2018-07-21 04:46:57 +00:00
let g:ale_fixers = { 'python': 'autopep8' }
let g:ale_python_mypy_options = "--ignore-missing-imports"
let g:ale_python_pylint_options = "--disable=C"
let g:ale_python_flake8_options = "--ignore=E221"
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %s% (code)% [%severity%]'
let g:ale_statusline_format = ['⨉ %d', '⚠ %d', '⬥ ok']
let g:ale_lint_delay = 500 " relint max once per [amount] milliseconds
highlight ALEError cterm=undercurl ctermfg=196
highlight ALEInfo cterm=undercurl ctermfg=14
hi ALEErrorSign ctermfg=red ctermbg=none
hi ALEWarningSign ctermfg=yellow ctermbg=none
" }}}
" Deoplete {{{
let g:deoplete#enable_at_startup = 1
set completeopt-=preview
2018-07-21 04:46:57 +00:00
call deoplete#custom#option('max_list', 100000)
call deoplete#custom#option('min_pattern_length', 2)
if !exists('g:deoplete#omni#input_patterns')
let g:deoplete#omni#input_patterns = {}
endif
let g:deoplete#sources#jedi#server_timeout = 120
let g:deoplete#sources#jedi#show_docstring = 1
let g:deoplete#enable_ignore_case = 1
let g:deoplete#enable_smart_case = 1
let g:context_filetype#same_filetypes = {}
let g:context_filetype#same_filetypes._ = '_'
"}}}
2018-02-04 16:14:51 +00:00
" Wintabs {{{
let g:wintabs_ui_active_higroup = 'TabLineSel'
let g:wintabs_switchbuf='useopen,usetab'
2018-07-21 04:46:57 +00:00
let g:wintabs_display='statusline'
let intertabSpace= ''
let activeVimTabChar = '┃ '
2018-07-21 04:46:57 +00:00
let g:wintabs_ui_sep_leftmost=activeVimTabChar
let g:wintabs_ui_sep_inbetween=' '
let g:wintabs_ui_sep_rightmost=' '
let g:wintabs_ui_active_vimtab_left=activeVimTabChar
let g:wintabs_ui_active_vimtab_right=' '
2018-07-21 04:46:57 +00:00
let g:wintabs_ui_active_left=activeVimTabChar
let g:wintabs_ui_active_right=' '
2018-07-21 04:46:57 +00:00
let g:wintabs_ui_buffer_name_format='%t'
let g:wintabs_ui_vimtab_name_format='%n'
let g:wintabs_ui_arrow_left='«'
let g:wintabs_ui_arrow_right='»'
2018-02-04 16:14:51 +00:00
" }}}
2017-12-28 13:49:45 +00:00
" NerdTree {{{
autocmd StdinReadPre * let s:std_in=1
let NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.pyo$', '\.db$', '\.sqlite$', '.o$', 'bower_components', 'node_modules', '__pycache__']
let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']
let NERDTreeNaturalSort = 1
let NERDTreeShowHidden=1
let NERDTreeWinPos=1
let NERDTreeRespectWildIgnore = 1
let NERDTreeMinimalUI=1
let NERDTreeDirArrows = 1
let NERDTreeCascadeSingleChildDir=1
let NERDTreeCascadeOpenSingleChildDir=1
let NERDTreeQuitOnOpen = 1
let NERDTreeHijackNetrw = 0
let NERDTreeAutoCenter = 1
let g:NERDTreeDirArrowExpandable = '↠'
let g:NERDTreeDirArrowCollapsible = '↡'
2017-12-28 13:49:45 +00:00
" }}}
2018-07-21 04:46:57 +00:00
" Ranger {{{
function! <SID>ranger()
let l:temp = tempname()
execute 'silent !st -e ranger --choosefiles='.shellescape(l:temp).' $PWD'
if !filereadable(temp)
redraw!
return
endif
let l:names = readfile(l:temp)
if empty(l:names)
redraw!
return
endif
execute 'edit '.fnameescape(l:names[0])
for l:name in l:names[1:]
execute 'argadd '.fnameescape(l:name)
endfor
redraw!
endfunction
" }}}
2017-12-28 13:49:45 +00:00
" Tmux navigator {{{
let g:tmux_navigator_no_mappings = 1
let g:tmux_navigator_save_on_switch = 1
nnoremap <silent> M-left :TmuxNavigateLeft<cr>
nnoremap <silent> M-Down :TmuxNavigateDown<cr>
nnoremap <silent> M-Up :TmuxNavigateUp<cr>
nnoremap <silent> M-Right :TmuxNavigateRight<cr>
nnoremap <silent> M-Tab :TmuxNavigatePrevious<cr>
2017-12-28 13:49:45 +00:00
" }}}
" Goyo {{{
function! s:goyo_enter()
let b:quitting = 0
let b:quitting_bang = 0
autocmd QuitPre <buffer> let b:quitting = 1
cabbrev <buffer> q! let b:quitting_bang = 1 <bar> q!
endfunction
function! s:goyo_leave()
" Quit Vim if this is the only remaining buffer
if b:quitting && len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) == 1
if b:quitting_bang
qa!
else
qa
endif
endif
endfunction
autocmd! User GoyoEnter call <SID>goyo_enter()
autocmd! User GoyoLeave call <SID>goyo_leave()
" }}}
" Fzf {{{
" use bottom positioned 20% height bottom split
let g:fzf_layout = { 'down': '~20%' }
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-s': 'split',
\ 'ctrl-v': 'vsplit' }
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Clear'],
\ 'hl': ['fg', 'String'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ 'rg --column --line-number --hidden --ignore-case --no-heading --color=always '.shellescape(<q-args>), 1,
\ <bang>0 ? fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}, 'up:60%')
\ : fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}, 'right:50%:hidden', '?'),
\ <bang>0)
" only use FZF shortcuts in non diff-mode
if !&diff
nnoremap <C-p> :Files<Cr>
nnoremap <C-g> :Rg<Cr>
endif
" }}}
"Mappings {{{
2018-07-21 04:46:57 +00:00
" Open ranger as a file chooser
nnoremap <leader>R :call <SID>ranger()<CR>
nnoremap <silent> <F2> :NERDTreeToggle<CR>
nnoremap <silent> <F3> :NERDTreeFind<CR>
map <F6> :setlocal spell! spelllang=es<CR>
map <F7> :setlocal spell! spelllang=en<CR>
map <F8> :!w<Enter>:!pdflatex <C-r>%<Enter>
map <F9> :set nospell<CR>
nmap <silent> <F10> <Plug>(ale_previous_wrap)
nmap <silent> <F11> <Plug>(ale_next_wrap)
nnoremap <leader>f :Neoformat<CR>
vnoremap <leader>f :Neoformat<CR>
2018-05-26 20:06:45 +00:00
nnoremap <leader>pi :PlugInstall<CR>
nnoremap <leader>pu :PlugUpdate<CR>
nnoremap <leader>pU :PlugUpgrade<CR>
nnoremap <leader>pc :PlugClean<CR>
" fzf & rg
nnoremap <C-p> :Files<Cr>
nnoremap <C-g> :Rg<Cr>
nnoremap <C-h> :History<CR>
nnoremap <C-b> :Buffers<CR>
" super quick search and replace
nnoremap <Space>' :'{,'}s/\<<C-r>=expand("<cword>")<CR>\>/
nnoremap <Space>¿ :%s/\<<C-r>=expand("<cword>")<CR>\>/
" Learn vim keys the hard way
nnoremap <silent> <Left> :vertical resize -2<CR>
nnoremap <silent> <Right> :vertical resize +2<CR>
2018-07-21 04:46:57 +00:00
nnoremap <silent> <Up> :resize -1<CR>
nnoremap <silent> <Down> :resize +1<CR>
inoremap jk <esc>
cnoremap jk <C-c>
2018-07-21 04:46:57 +00:00
nnoremap <silent> <leader>ev :vsplit $MYVIMRC<CR>
nnoremap <silent> <leader>sv :source $MYVIMRC<CR>
nnoremap <leader>T :terminal<CR>
nnoremap <leader>s :split<CR>
nnoremap <leader>v :vsplit<CR>
nnoremap <leader>nv :vnew<CR>
nnoremap <leader>ns :new<CR>
" ensure that ctrl+u in insert mode can be reversed
" http://vim.wikia.com/wiki/Recover_from_accidental_Ctrl-U
inoremap <c-u> <c-g>u<c-u>
inoremap <c-w> <c-g>u<c-w>
" My vim wants to enter all the time, enter all the time
nnoremap <silent> <CR> i<CR><ESC>
" Fix indentation
nnoremap <leader>i mzgg=G`z<CR>
2018-07-21 04:46:57 +00:00
" deedee
nnoremap - dd<CR>p
inoremap <c-d> <esc>ddi
" LOUD
inoremap <m-u> <esc>viwUi
nnoremap <m-u> viwU
" Quotes
nnoremap <leader>" viw<esc>a"<esc>bi"<esc>lel
" Unhighlight search terms
2018-07-04 19:27:13 +00:00
nnoremap <silent> <leader><space> :noh<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>
" What about the Q
nnoremap Q <nop>
map q <nop>
2018-07-21 04:46:57 +00:00
" j = gj :: k = gk while preserving numbered jumps ie. 12j or 30k
nnoremap <buffer><silent><expr>j v:count ? 'j' : 'gj'
nnoremap <buffer><silent><expr>k v:count ? 'k' : 'gk'
vnoremap <buffer><silent><expr>j v:count ? 'j' : 'gj'
vnoremap <buffer><silent><expr>k v:count ? 'k' : 'gk'
" Use tab for indenting
vnoremap <Tab> >gv|
vnoremap <S-Tab> <gv
nnoremap <Tab> >gv|
nnoremap <S-Tab> <gv
noremap <silent> <Home> g<Home>
noremap <silent> <End> g<End>
inoremap <silent> <Home> <C-o>g<Home>
inoremap <silent> <End> <C-o>g<End>
2018-07-21 04:46:57 +00:00
nnoremap H 0
nnoremap L $
vnoremap H 0
vnoremap L $
2018-07-21 04:46:57 +00:00
noremap Y 0y$
" Center screen when jumping and moving
nnoremap <silent> n :norm! nzz<CR>
nnoremap <silent> N :norm! Nzz<CR>
vnoremap <silent> n :norm! nzz<CR>
vnoremap <silent> N :norm! Nzz<CR>
" Tabs
nnoremap <C-Tab> :tabnew<CR>
2018-07-04 19:27:13 +00:00
nnoremap <M-Tab> <Plug>(wintabs_close)<CR>
nnoremap <Tab> <Plug>(wintabs_next)<CR>
nnoremap <S-Tab> <Plug>(wintabs_previous)<CR>
" Alt to switch windows
nnoremap <M-j> <C-W><C-J>
nnoremap <M-k> <C-W><C-K>
nnoremap <M-l> <C-W><C-L>
nnoremap <M-h> <C-W><C-H>
inoremap <A-h> <Esc><C-w>h
inoremap <A-j> <Esc><C-w>j
inoremap <A-k> <Esc><C-w>k
inoremap <A-l> <Esc><C-w>l
" Terminal movement
tnoremap <Esc> <C-\><C-n>
tnoremap <M-h> <C-\><C-n><C-w>h
tnoremap <M-j> <C-\><C-n><C-w>j
tnoremap <M-k> <C-\><C-n><C-w>k
tnoremap <M-l> <C-\><C-n><C-w>l
" Shift butterfinger
:command! WQ wq
:command! Wq wq
:command! Wqa wqa
:command! Wa wa
:command! WA wa
:command! W w
:command! Q q
:command! Qa qa
:command! QA qa
" }}}
" Enhanced Diff {{{
" started In Diff-Mode set diffexpr (plugin not loaded yet)
if &diff
let &diffexpr='EnhancedDiff#Diff("git diff", "--diff-algorithm=patience")'
endif
" }}}
2018-07-21 04:46:57 +00:00
" Stuff i'll probably use if i remember to {{{
" global replace
vnoremap <Leader>sw "hy
\ :let b:sub = input('global replacement: ') <Bar>
\ if b:sub !=? '' <Bar>
\ let b:rep = substitute(getreg('h'), '/', '\\/', 'g') <Bar>
\ execute '%s/'.b:rep."/".b:sub.'/g' <Bar>
\ unlet b:sub b:rep <Bar>
\ endif <CR>
nnoremap <Leader>sw
\ :let b:sub = input('global replacement: ') <Bar>
\ if b:sub !=? '' <Bar>
\ execute "%s/<C-r><C-w>/".b:sub.'/g' <Bar>
\ unlet b:sub <Bar>
\ endif <CR>
" prompt before each replace
vnoremap <Leader>cw "hy
\ :let b:sub = input('interactive replacement: ') <Bar>
\ if b:sub !=? '' <Bar>
\ let b:rep = substitute(getreg('h'), '/', '\\/', 'g') <Bar>
\ execute '%s/'.b:rep.'/'.b:sub.'/gc' <Bar>
\ unlet b:sub b:rep <Bar>
\ endif <CR>
nnoremap <Leader>cw
\ :let b:sub = input('interactive replacement: ') <Bar>
\ if b:sub !=? '' <Bar>
\ execute "%s/<C-r><C-w>/".b:sub.'/gc' <Bar>
\ unlet b:sub <Bar>
\ endif <CR>
" highlight long lines
let w:longlines = matchadd('ColorColumn', '\%'.&tw.'v', &tw)
nnoremap <silent> <Leader>ll
\ :if exists('w:longlines') <Bar>
\ silent! call matchdelete(w:longlines) <Bar>
\ unlet w:longlines <Bar>
\ elseif &textwidth > 0 <Bar>
\ let w:longlines = matchadd('ColorColumn', '\%'.&textwidth.'v', &textwidth) <Bar>
\ else <Bar>
\ let w:longlines = matchadd('ColorColumn', '\%80v', 80) <Bar>
\ endif <CR>
" local keyword jump
nnoremap <Leader>fw
\ [I:let b:jump = input('Go To: ') <Bar>
\ if b:jump !=? '' <Bar>
\ execute "normal! ".b:jump."[\t" <Bar>
\ unlet b:jump <Bar>
\ endif <CR><Paste>
" }}}
" vim:foldmethod=marker:foldlevel=0