Improve vim's paste, todo comments, and window operations.
This commit is contained in:
1 parent
69214f1c11
commit
686ae41c42
1 file changed
+66
-4
@@ -1,7 +1,6 @@
|
||||
filetype plugin indent on
|
||||
syntax on
|
||||
|
||||
"colorscheme wildcharm
|
||||
colorscheme habamax
|
||||
|
||||
set nobackup nowritebackup
|
||||
@@ -9,7 +8,7 @@ set noswapfile
|
||||
|
||||
set number
|
||||
|
||||
set tabstop=4
|
||||
set tabstop=8
|
||||
set shiftwidth=4
|
||||
set softtabstop=4
|
||||
set expandtab
|
||||
@@ -54,16 +53,17 @@ set signcolumn=auto
|
||||
:nnoremap > :cn<CR>
|
||||
:nnoremap < :cp<CR>
|
||||
|
||||
:nnoremap \\ :noh<CR>
|
||||
:nnoremap g/ :noh<CR>
|
||||
|
||||
:nnoremap E :Ex<CR>
|
||||
|
||||
:nnoremap <space>z :set relativenumber<CR>
|
||||
:nnoremap <space>x :set norelativenumber<CR>
|
||||
|
||||
xnoremap p "_dP
|
||||
"xnoremap p "_dP
|
||||
|
||||
:nnoremap gb :make<CR>
|
||||
:nnoremap gr :make run<CR>
|
||||
|
||||
:nnoremap gw :bdelete<CR>
|
||||
|
||||
@@ -93,3 +93,65 @@ function! AlignLine(line, sep, maxpos, extra)
|
||||
let spaces = repeat(' ', a:maxpos - strlen(m[1]) + a:extra)
|
||||
return m[1] . spaces . m[2]
|
||||
endfunction
|
||||
|
||||
" Window Operations
|
||||
function! CreateOrSelectWindow()
|
||||
let win_count = winnr('$')
|
||||
|
||||
if win_count == 1
|
||||
execute 'vsplit'
|
||||
endif
|
||||
|
||||
execute '2wincmd w'
|
||||
endfunction
|
||||
|
||||
function! PutIntoShade()
|
||||
let max_width = float2nr(&columns * 0.95)
|
||||
let min_width = float2nr(&columns * 0.5)
|
||||
|
||||
if winwidth(0) > min_width
|
||||
execute 'vertical resize ' . min_width
|
||||
elseif winwidth(0) <= min_width
|
||||
execute 'vertical resize ' . max_width
|
||||
endif
|
||||
endfunction
|
||||
|
||||
:nnoremap ! :1wincmd w<CR>
|
||||
:nnoremap @ :call CreateOrSelectWindow()<CR>
|
||||
:nnoremap # :call PutIntoShade()<CR>
|
||||
|
||||
" Preserve paste line column
|
||||
function! PasteAbove()
|
||||
let c = col('.')
|
||||
normal! P
|
||||
call cursor(0, c)
|
||||
endfunction
|
||||
|
||||
function! PasteBelow()
|
||||
let c = col('.')
|
||||
normal! p
|
||||
call cursor(0, c)
|
||||
endfunction
|
||||
|
||||
:nnoremap P :call PasteAbove()<CR>
|
||||
:nnoremap p :call PasteBelow()<CR>
|
||||
|
||||
" Todo Comments highlights
|
||||
" Colors: https://vim.fandom.com/wiki/Xterm256_color_names_for_console_Vim
|
||||
" NOTE: These are confirmed to work with 'habamax' color scheme.
|
||||
:highlight TODOPerf term=bold,underline cterm=bold,underline ctermfg=93 " purple
|
||||
:highlight TODOHack term=bold,underline cterm=bold,underline ctermfg=214 " orange
|
||||
:highlight TODOTodo term=bold,underline cterm=bold,underline ctermfg=51 " cyan
|
||||
:highlight TODONote term=bold,underline cterm=bold,underline ctermfg=46 " green
|
||||
:highlight TODOFix term=bold,underline cterm=bold,underline ctermfg=196 " green
|
||||
:highlight TODOWarning term=bold,underline cterm=bold,underline ctermfg=214 " orange
|
||||
|
||||
augroup HiglightTODO
|
||||
autocmd!
|
||||
autocmd WinEnter,VimEnter * :silent! call matchadd('TODOPerf', 'PERF:', -1)
|
||||
autocmd WinEnter,VimEnter * :silent! call matchadd('TODOHack', 'HACK:', -1)
|
||||
autocmd WinEnter,VimEnter * :silent! call matchadd('TODOTodo', 'TODO:', -1)
|
||||
autocmd WinEnter,VimEnter * :silent! call matchadd('TODONote', 'NOTE:', -1)
|
||||
autocmd WinEnter,VimEnter * :silent! call matchadd('TODOFix', 'FIX:', -1)
|
||||
autocmd WinEnter,VimEnter * :silent! call matchadd('TODOWarning', 'WARNING:', -1)
|
||||
augroup END
|
||||
Reference in new issue
Block a user