222 lines
5.8 KiB
VimL
222 lines
5.8 KiB
VimL
set history=700
|
|
filetype plugin on
|
|
filetype indent on
|
|
set autoread
|
|
let mapleader = ","
|
|
let g:mapleader = ","
|
|
nmap <leader>w :w!<cr>
|
|
set so=7
|
|
set wildmenu
|
|
set wildignore=*.o,*~,*.pyc
|
|
set ruler
|
|
set cmdheight=2
|
|
set hid
|
|
set backspace=eol,start,indent
|
|
set whichwrap+=<,>,h,l
|
|
set ignorecase
|
|
set smartcase
|
|
set hlsearch
|
|
set incsearch
|
|
set lazyredraw
|
|
set magic
|
|
set showmatch
|
|
set mat=2
|
|
set noerrorbells
|
|
set novisualbell
|
|
set t_vb=
|
|
set tm=500
|
|
syntax enable
|
|
colorscheme desert
|
|
set background=dark
|
|
if has("gui_running")
|
|
set guioptions-=T
|
|
set guioptions+=e
|
|
set t_Co=256
|
|
set guitablabel=%M\ %t
|
|
endif
|
|
set encoding=utf8
|
|
set ffs=unix,dos,mac
|
|
set nobackup
|
|
set nowb
|
|
set noswapfile
|
|
set expandtab
|
|
set smarttab
|
|
set shiftwidth=4
|
|
set tabstop=4
|
|
set lbr
|
|
set tw=500
|
|
set ai "Auto indent
|
|
set si "Smart indent
|
|
set wrap "Wrap lines
|
|
cnoreabbrev hex %!xxd
|
|
vnoremap <silent> * :call VisualSelection('f')<CR>
|
|
vnoremap <silent> # :call VisualSelection('b')<CR>
|
|
map j gj
|
|
map k gk
|
|
map <space> /
|
|
map <c-space> ?
|
|
map <silent> <leader><cr> :noh<cr>
|
|
map <C-j> <C-W>j
|
|
map <C-k> <C-W>k
|
|
map <C-h> <C-W>h
|
|
map <C-l> <C-W>l
|
|
map <leader>bd :Bclose<cr>
|
|
map <leader>ba :1,1000 bd!<cr>
|
|
map <leader>tn :tabnew<cr>
|
|
map <leader>to :tabonly<cr>
|
|
map <leader>tc :tabclose<cr>
|
|
map <leader>tm :tabmove
|
|
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
|
|
map <leader>cd :cd %:p:h<cr>:pwd<cr>
|
|
try
|
|
set switchbuf=useopen,usetab,newtab
|
|
set stal=2
|
|
catch
|
|
endtry
|
|
autocmd BufReadPost *
|
|
\ if line("'\"") > 0 && line("'\"") <= line("$") |
|
|
\ exe "normal! g`\"" |
|
|
\ endif
|
|
set viminfo^=%
|
|
set laststatus=2
|
|
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l/%L\ \ Column:\ %c
|
|
map 0 ^
|
|
nmap <M-j> mz:m+<cr>`z
|
|
nmap <M-k> mz:m-2<cr>`z
|
|
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
|
|
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
|
|
if has("mac") || has("macunix")
|
|
nmap <D-j> <M-j>
|
|
nmap <D-k> <M-k>
|
|
vmap <D-j> <M-j>
|
|
vmap <D-k> <M-k>
|
|
endif
|
|
func! DeleteTrailingWS()
|
|
exe "normal mz"
|
|
%s/\s\+$//ge
|
|
exe "normal `z"
|
|
endfunc
|
|
autocmd BufWrite *.py :call DeleteTrailingWS()
|
|
autocmd BufWrite *.coffee :call DeleteTrailingWS()
|
|
vnoremap <silent> gv :call VisualSelection('gv')<CR>
|
|
map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left>
|
|
map <leader><space> :vimgrep // <C-R>%<C-A><right><right><right><right><right><right><right><right><right>
|
|
vnoremap <silent> <leader>r :call VisualSelection('replace')<CR>
|
|
map <leader>cc :botright cope<cr>
|
|
map <leader>co ggVGy:tabnew<cr>:set syntax=qf<cr>pgg
|
|
map <leader>n :cn<cr>
|
|
map <leader>p :cp<cr>
|
|
map <leader>ss :setlocal spell!<cr>
|
|
map <leader>sn ]s
|
|
map <leader>sp [s
|
|
map <leader>sa zg
|
|
map <leader>s? z=
|
|
noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
|
|
map <leader>q :e ~/buffer<cr>
|
|
map <leader>pp :setlocal paste!<cr>
|
|
function! CmdLine(str)
|
|
exe "menu Foo.Bar :" . a:str
|
|
emenu Foo.Bar
|
|
unmenu Foo
|
|
endfunction
|
|
function! VisualSelection(direction) range
|
|
let l:saved_reg = @"
|
|
execute "normal! vgvy"
|
|
|
|
let l:pattern = escape(@", '\\/.*$^~[]')
|
|
let l:pattern = substitute(l:pattern, "\n$", "", "")
|
|
|
|
if a:direction == 'b'
|
|
execute "normal ?" . l:pattern . "^M"
|
|
elseif a:direction == 'gv'
|
|
call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.')
|
|
elseif a:direction == 'replace'
|
|
call CmdLine("%s" . '/'. l:pattern . '/')
|
|
elseif a:direction == 'f'
|
|
execute "normal /" . l:pattern . "^M"
|
|
endif
|
|
|
|
let @/ = l:pattern
|
|
let @" = l:saved_reg
|
|
endfunction
|
|
function! HasPaste()
|
|
if &paste
|
|
return 'PASTE MODE '
|
|
en
|
|
return ''
|
|
endfunction
|
|
command! Bclose call <SID>BufcloseCloseIt()
|
|
function! <SID>BufcloseCloseIt()
|
|
let l:currentBufNum = bufnr("%")
|
|
let l:alternateBufNum = bufnr("#")
|
|
|
|
if buflisted(l:alternateBufNum)
|
|
buffer #
|
|
else
|
|
bnext
|
|
endif
|
|
|
|
if bufnr("%") == l:currentBufNum
|
|
new
|
|
endif
|
|
|
|
if buflisted(l:currentBufNum)
|
|
execute("bdelete! ".l:currentBufNum)
|
|
endif
|
|
endfunction
|
|
" Commenting blocks of code.
|
|
autocmd FileType c,cpp,java,scala,javascript let b:comment_leader = '// '
|
|
autocmd FileType sh,ruby,python let b:comment_leader = '# '
|
|
autocmd FileType conf,fstab let b:comment_leader = '# '
|
|
autocmd FileType tex let b:comment_leader = '% '
|
|
autocmd FileType vim let b:comment_leader = '" '
|
|
noremap <leader>cc :<C-B><C-E>s/^/<C-R>=escape(b:comment_leader,'\/')<CR>/<CR>:nohlsearch<CR>
|
|
noremap <leader>cu :<C-B><C-E>s/^\V<C-R>=escape(b:comment_leader,'\/')<CR>//e<CR>:nohlsearch<CR>
|
|
vnoremap <leader>cc :<C-B><C-E>s/^/<C-R>=escape(b:comment_leader,'\/')<CR>/<CR>:nohlsearch<CR>
|
|
vnoremap <leader>cu :<C-B><C-E>s/^\V<C-R>=escape(b:comment_leader,'\/')<CR>//e<CR>:nohlsearch<CR>
|
|
|
|
highlight ColorColumn ctermbg=magenta
|
|
call matchadd('ColorColumn', '\%80v', 100)
|
|
|
|
nnoremap <silent> n n:call HLNext(0.4)<cr>
|
|
nnoremap <silent> N N:call HLNext(0.4)<cr>
|
|
|
|
highlight WhiteOnRed ctermbg=red ctermfg=white
|
|
|
|
function! HLNext(blinktime)
|
|
let [bufnum, lnum, col, off] = getpos('.')
|
|
let machlen = strlen(matchstr(strpart(getline('.'), col-1),@/))
|
|
let target_pat = '\c\%#'.@/
|
|
let blinks = 3
|
|
for n in range(1, blinks)
|
|
let red = matchadd('WhiteOnRed', target_pat, 101)
|
|
redraw
|
|
exec 'sleep ' . float2nr(a:blinktime / (2*blinks) * 1000) . 'm'
|
|
call matchdelete(red)
|
|
redraw
|
|
exec 'sleep ' . float2nr(a:blinktime / (2*blinks) * 1000) . 'm'
|
|
endfor
|
|
endfunction
|
|
|
|
" VimScript Highlighting is so fucking distracting
|
|
augroup VimNoHighlight
|
|
autocmd!
|
|
autocmd BufEnter .vimrc syntax off
|
|
augroup END
|
|
|
|
augroup NoEdits
|
|
autocmd!
|
|
autocmd SwapExists * let v:swapchoice = 'o'
|
|
autocmd SwapExists * echomsg ErrorMsg
|
|
autocmd SwapExists * echo 'Duplicate edit session (you are now editing readonly)'
|
|
autocmd SwapExists * echohl None
|
|
augroup END
|
|
|
|
inoremap <expr> <C-K> ShowDigraphs
|
|
|
|
function! ShowDigraphs()
|
|
digraphs
|
|
call getchar()
|
|
return "\<C-K>"
|
|
endfunction
|