vim/vimrc

200 lines
4.6 KiB
VimL
Raw Normal View History

2018-11-17 20:22:58 +00:00
"#commands{{{
2018-11-21 14:28:03 +00:00
" TrimWhitespace{{{
2018-11-17 20:22:58 +00:00
command! -range=% TrimWhitespace let b:wv = winsaveview() |
\ keeppattern <line1>,<line2>s/\s\+$// |
\ call winrestview(b:wv)
2018-11-21 14:28:03 +00:00
"}}}
" Scratch, ScratchVertical{{{
2018-11-21 14:25:30 +00:00
command! Scratch new | setlocal buftype=nofile | setlocal bufhidden=hide | setlocal noswapfile
command! ScratchVertical vnew | setlocal buftype=nofile | setlocal bufhidden=hide | setlocal noswapfile
2018-11-21 14:28:03 +00:00
"}}}
2018-11-17 20:22:58 +00:00
"}}}
" #settings {{{
2018-09-25 13:54:09 +00:00
scriptencoding utf-8
syntax on
2019-09-13 14:27:55 +00:00
set fillchars=stl:\ ,stlnc:\ ,vert:\|,fold:\
2018-09-25 13:54:09 +00:00
" persisitent undo file
set undofile
2019-08-08 22:42:57 +00:00
set undodir=~/.vim/.vimtmp
set backupdir=~/.vim/.vimtmp
set directory=~/.vim/.vimtmp
2018-09-25 13:54:09 +00:00
2018-10-10 08:31:33 +00:00
set viewoptions-=options
2020-04-01 16:26:37 +00:00
set title
2018-09-25 13:54:09 +00:00
set ignorecase
set smartcase
set wildmenu
set wildmode=longest:full,full
2018-10-08 18:28:02 +00:00
set wildignore+=/node_modules/,dist/
2018-09-25 13:54:09 +00:00
2018-11-02 20:25:06 +00:00
" Use ag over grep
if executable('ag')
set grepprg=ag\ --nogroup\ --nocolor\ --ignore\ node_modules
endif
2020-03-19 17:08:41 +00:00
colorscheme peachpuff
2018-09-25 13:54:09 +00:00
set hidden
set hlsearch
2019-02-09 22:15:36 +00:00
set completeopt=menuone
2018-09-25 13:54:09 +00:00
set nospell
set spelllang=en_gb
2018-11-25 19:32:05 +00:00
set diffopt+=vertical
2019-09-18 13:28:58 +00:00
set rnu nu
2018-09-25 13:54:09 +00:00
set tabstop=8
set softtabstop=2
set shiftwidth=2
set shiftround
set expandtab
set autoindent
2020-02-06 14:54:37 +00:00
set textwidth=120
2018-09-25 13:54:09 +00:00
set formatoptions=cq
set wrapmargin=0
2020-03-19 17:08:41 +00:00
set nocursorline
2018-09-25 13:54:09 +00:00
set iskeyword+=-
set showcmd
set incsearch
set laststatus=2
set shortmess=aoOT
2019-06-16 10:38:43 +00:00
set foldmethod=indent
2018-09-25 13:54:09 +00:00
set showmode
set autoindent
set breakindent
2018-11-23 11:14:42 +00:00
set showbreak=\ \ ↳\
2018-09-25 13:54:09 +00:00
set mouse=a
set listchars=eol,tab:>-,trail:~,extends:>,precedes:<,space
set foldtext=MyFoldText()
2019-06-03 20:16:35 +00:00
set conceallevel=0
2018-11-05 20:12:38 +00:00
"----------------------------------------------------------------------------}}}
2018-09-25 13:54:09 +00:00
" #mappings {{{
let g:mapleader = ' '
2019-09-18 13:28:58 +00:00
" #syntax
nnoremap <silent> <cr>s :syntax on<cr>
nnoremap <silent> <cr>S :syntax off<cr>
2018-11-19 13:38:12 +00:00
" miscallaneous {{{
2018-11-15 21:25:44 +00:00
nnoremap 0 ^
2018-11-19 17:02:54 +00:00
nnoremap <silent><space>cs :let @/=""<cr>
2019-09-12 17:35:01 +00:00
nnoremap <space>: :setlocal number<CR>:
2018-09-25 13:54:09 +00:00
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;
2019-03-01 10:32:01 +00:00
nnoremap <space>;; A;<esc>
nnoremap <space>;j jA;<esc>
nnoremap <space>,, A,<esc>
nnoremap <space>,j jA,<esc>
2018-09-25 13:54:09 +00:00
" Focus on current fold, close the rest
nnoremap <silent> <space>zz zMzvzt
" replace current word with last yanked/deleted text
2019-02-22 22:07:25 +00:00
nnoremap <silent> <space>rw "_diwP
2018-09-25 13:54:09 +00:00
" 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
2019-09-12 17:35:01 +00:00
" FIXME i want fixme!!!
nnoremap <space>td :grep -RE '(TODO\\|FIXME)' .<CR>:botright cwindow<CR>:echo len(getqflist()) 'TODOs'<CR>
2018-09-25 13:54:09 +00:00
" devdocs mapping
nnoremap <space>dd :DD<CR>
" write and delete current buffer
nnoremap <space>bx :w\|bd<cr>
2018-11-19 13:38:12 +00:00
" sync highlighting from start
nnoremap <silent><space>ss :syntax sync fromstart<CR>
2018-09-25 13:54:09 +00:00
2018-11-12 12:29:32 +00:00
"}}}
2018-11-19 13:38:12 +00:00
" terminal{{{
2018-12-12 09:09:04 +00:00
if has('terminal')
tnoremap <Esc> <C-\><C-n>
endif
2018-09-25 13:54:09 +00:00
"}}}
2019-05-26 23:10:32 +00:00
" windows{{{
2020-02-26 12:28:12 +00:00
nnoremap <space>ww :resize<CR>:vertical resize<CR>
2019-05-26 23:10:32 +00:00
" }}}
2018-11-19 13:38:12 +00:00
" git mappings {{{
2018-11-25 19:32:05 +00:00
" also see vim-fugitive plugin section
2018-09-25 13:54:09 +00:00
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>
2018-11-25 22:00:51 +00:00
nnoremap <space>gP :!clear; echo 'git push'; git push<CR>
2018-09-25 13:54:09 +00:00
2018-11-05 20:12:38 +00:00
"}}}
2018-11-27 21:57:06 +00:00
" movement/navigation{{{
2018-09-25 13:54:09 +00:00
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>
2018-11-27 21:57:06 +00:00
" alias for :tjump <cword>
nnoremap <space>tj g<C-]>
2018-12-02 21:31:01 +00:00
" alias for :ptjump <cword>
2018-11-27 21:57:06 +00:00
nnoremap <space>tp <C-w>g}
2018-09-25 13:54:09 +00:00
"}}}
2018-11-19 13:38:12 +00:00
" location list and quickfix mappings {{{
2018-09-25 13:54:09 +00:00
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>
2018-11-05 20:12:38 +00:00
"}}}
2018-11-19 13:38:12 +00:00
" insert mode mappings {{{
2018-09-25 13:54:09 +00:00
inoremap jkrg <c-o>:reg<cr>
inoremap :w<cr> :w<cr>
inoremap [:w<cr> :w<cr>
inoremap {:w<cr> :w<cr>
2018-11-19 13:38:12 +00:00
" working_with_underscores{{{
2018-11-15 21:25:44 +00:00
nnoremap <space>w f_l
nnoremap <space>b hT_
nnoremap <space>e lt_
onoremap u t_
onoremap U f_
2018-09-25 13:54:09 +00:00
"}}}
2018-11-05 20:12:38 +00:00
"----------------------------------------------------------------------------}}}
2018-12-02 22:33:19 +00:00
2020-05-20 12:31:35 +00:00
augroup gitcommit
autocmd!
2021-02-16 18:50:16 +00:00
autocmd FileType gitcommit 1
2020-05-20 12:31:35 +00:00
augroup END
2019-09-12 17:35:01 +00:00
2018-11-04 16:15:18 +00:00
" vim: set foldmethod=marker:
2020-05-20 12:31:35 +00:00
" #mappings {{{
" #mappings {{{
"