vim/vimrc

200 lines
4.6 KiB
VimL
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"#commands{{{
" TrimWhitespace{{{
command! -range=% TrimWhitespace let b:wv = winsaveview() |
\ keeppattern <line1>,<line2>s/\s\+$// |
\ call winrestview(b:wv)
"}}}
" Scratch, ScratchVertical{{{
command! Scratch new | setlocal buftype=nofile | setlocal bufhidden=hide | setlocal noswapfile
command! ScratchVertical vnew | setlocal buftype=nofile | setlocal bufhidden=hide | setlocal noswapfile
"}}}
"}}}
" #settings {{{
scriptencoding utf-8
syntax on
set fillchars=stl:\ ,stlnc:\ ,vert:\|,fold:\
" persisitent undo file
set undofile
set undodir=~/.vim/.vimtmp
set backupdir=~/.vim/.vimtmp
set directory=~/.vim/.vimtmp
set viewoptions-=options
set title
set ignorecase
set smartcase
set wildmenu
set wildmode=longest:full,full
set wildignore+=/node_modules/,dist/
" Use ag over grep
if executable('ag')
set grepprg=ag\ --nogroup\ --nocolor\ --ignore\ node_modules
endif
colorscheme peachpuff
set hidden
set hlsearch
set completeopt=menuone
set nospell
set spelllang=en_gb
set diffopt+=vertical
set rnu nu
set tabstop=8
set softtabstop=2
set shiftwidth=2
set shiftround
set expandtab
set autoindent
set textwidth=120
set formatoptions=cq
set wrapmargin=0
set nocursorline
set iskeyword+=-
set showcmd
set incsearch
set laststatus=2
set shortmess=aoOT
set foldmethod=indent
set showmode
set autoindent
set breakindent
set showbreak=\ \ ↳\
set mouse=a
set listchars=eol,tab:>-,trail:~,extends:>,precedes:<,space
set foldtext=MyFoldText()
set conceallevel=0
"----------------------------------------------------------------------------}}}
" #mappings {{{
let g:mapleader = ' '
" #syntax
nnoremap <silent> <cr>s :syntax on<cr>
nnoremap <silent> <cr>S :syntax off<cr>
" miscallaneous {{{
nnoremap 0 ^
nnoremap <silent><space>cs :let @/=""<cr>
nnoremap <space>: :setlocal number<CR>:
nnoremap <silent> <space>rc :so $MYVIMRC<CR>
nnoremap <silent><expr> <space>nh (&hls && v:hlsearch ? ':nohls' : ':set hls')."\n"
nnoremap <silent> <space>sl :set invlist<CR>
nnoremap <space>aa A<left>
nnoremap <space>a2 A<left><left>
nnoremap <space>ab A<C-o>B
nnoremap <space>co :!clear;
nnoremap <space>;; A;<esc>
nnoremap <space>;j jA;<esc>
nnoremap <space>,, A,<esc>
nnoremap <space>,j jA,<esc>
" Focus on current fold, close the rest
nnoremap <silent> <space>zz zMzvzt
" replace current word with last yanked/deleted text
nnoremap <silent> <space>rw "_diwP
" replace current word with last yanked text
nnoremap <silent> <space>ry diw"0P
" quick grep of visual selection
vnoremap <space>gr y:grep! -R <C-r>" .
" open quickfix window of TODOs
" FIXME i want fixme!!!
nnoremap <space>td :grep -RE '(TODO\\|FIXME)' .<CR>:botright cwindow<CR>:echo len(getqflist()) 'TODOs'<CR>
" devdocs mapping
nnoremap <space>dd :DD<CR>
" write and delete current buffer
nnoremap <space>bx :w\|bd<cr>
" sync highlighting from start
nnoremap <silent><space>ss :syntax sync fromstart<CR>
"}}}
" terminal{{{
if has('terminal')
tnoremap <Esc> <C-\><C-n>
endif
"}}}
" windows{{{
nnoremap <space>ww :resize<CR>:vertical resize<CR>
" }}}
" git mappings {{{
" also see vim-fugitive plugin section
nnoremap <space>gD :!clear; echo 'git diff'; git diff<CR>
nnoremap <space>ga :!clear; git add %; git status<CR>
nnoremap <space>gA :!clear; git add .; git status<CR>
nnoremap <space>gg :!clear; git add %; git commit -m ''<Left>
nnoremap <space>gP :!clear; echo 'git push'; git push<CR>
"}}}
" movement/navigation{{{
nnoremap <Esc>j :resize -5<CR>
nnoremap <Esc>k :resize +5<CR>
nnoremap <Esc>l :vertical resize +5<CR>
nnoremap <Esc>h :vertical resize -5<CR>
" alias for :tjump <cword>
nnoremap <space>tj g<C-]>
" alias for :ptjump <cword>
nnoremap <space>tp <C-w>g}
"}}}
" location list and quickfix mappings {{{
nnoremap <space>lo :botright lwindow<CR>
nnoremap <up> :lprev<CR>zv
nnoremap <down> :lnext<CR>zv
nnoremap <space>lc :lclose<CR>
nnoremap <space>lh :lhistory<CR>
nnoremap <space>lp :lolder<CR>
nnoremap <space>ln :lnewer<CR>
nnoremap <space>qo :botright cwindow<CR>
nnoremap <left> :cprev<CR>zv
nnoremap <right> :cnext<CR>zv
nnoremap <space>qc :cclose<CR>
nnoremap <space>qh :chistory<CR>
nnoremap <space>qp :colder<CR>
nnoremap <space>qn :cnewer<CR>
"}}}
" insert mode mappings {{{
inoremap jkrg <c-o>:reg<cr>
inoremap :w<cr> :w<cr>
inoremap [:w<cr> :w<cr>
inoremap {:w<cr> :w<cr>
" working_with_underscores{{{
nnoremap <space>w f_l
nnoremap <space>b hT_
nnoremap <space>e lt_
onoremap u t_
onoremap U f_
"}}}
"----------------------------------------------------------------------------}}}
augroup gitcommit
autocmd!
autocmd FileType gitcommit 1 | startinsert
augroup END
" vim: set foldmethod=marker:
" #mappings {{{
" #mappings {{{
"