From d9b2d6fc98eb876fede2c2005290a27d34f22e8f Mon Sep 17 00:00:00 2001 From: Kevin MacMartin Date: Sun, 2 Nov 2014 18:19:37 -0500 Subject: [PATCH] Improve/fix organization+naming for splits + load help @ 33% width --- vim/config/after.vim | 9 +++-- vim/config/keyboard.vim | 24 ++++++------ vim/config/settings.vim | 84 +++++++++++++++++++++-------------------- 3 files changed, 62 insertions(+), 55 deletions(-) diff --git a/vim/config/after.vim b/vim/config/after.vim index 10e938b..a795f00 100644 --- a/vim/config/after.vim +++ b/vim/config/after.vim @@ -43,13 +43,16 @@ endif "filtype specific settings autocmd Filetype text,mkd,mkdc,gitcommit,notes,mail,notmuch,rst,taskreport setlocal nonumber spell nolist linebreak breakat&vim breakat-=* breakat-=. breakat-=/ breakat-=? breakat-=, breakat-=: breakat-=; breakat-=! "set some defaults for word processing autocmd Filetype text,gitcommit,notes,mail,notmuch,rst,taskreport setlocal wrap - autocmd FileType help* wincmd L "help windows always open vertically - autocmd FileType help* vertical resize 80 "set the window size to 80 cols - autocmd FileType help* setlocal nocursorline "remove the horizontal cursor line autocmd FileType tmux,taskrc setlocal commentstring=#\ %s "set the comment string to # autocmd FileType slrnrc setlocal commentstring=%%\ %s "set the comment string to % + + "special side/bottom-bar settings to apply when opened autocmd BufEnter,FileType taskreport,qf,help* setlocal nowrap nocursorcolumn "disable text wrapping and the vertical cursor line autocmd BufEnter,FileType extradite setlocal number "enable line numbers in extradite + autocmd BufEnter,FileType help* setlocal nocursorline "remove the horizontal cursor line + + "load help as a vertical split (sidebar) using one third of the window + autocmd BufEnter,FileType help* wincmd L|wincmd h|vs|wincmd =|q|wincmd l "settings for buffers in diff mode autocmd VimEnter,FilterWritePre * if &diff|setlocal nofoldenable|endif diff --git a/vim/config/keyboard.vim b/vim/config/keyboard.vim index 47b8185..b4ddb58 100644 --- a/vim/config/keyboard.vim +++ b/vim/config/keyboard.vim @@ -72,11 +72,11 @@ " { | (N) -> rotate counter-clockwise " } | (N) -> rotate clockwise " ] | (N) -> split vertically -" 0 | (N) -> create a vertical split 25% of the window -" ) | (N) -> create a vertical split 75% of the window +" 0 | (N) -> create a vertical split 33% of the window +" ) | (N) -> create a vertical split 66% of the window " [ | (N) -> split horizontally -" 9 | (N) -> create a horizontal split 25% of the window -" ( | (N) -> create a horizontal split 75% of the window +" 9 | (N) -> create a horizontal split 33% of the window +" ( | (N) -> create a horizontal split 66% of the window " " (display) " | (N) -> reset window and clear search @@ -326,10 +326,10 @@ cabbrev gitstatus ':Gstatus' cabbrev GitCommit ':Gcommit' cabbrev gitcommit ':Gcommit' - cabbrev vs25 ':VS25' - cabbrev vs75 ':VS75' - cabbrev sp25 ':SP25' - cabbrev sp75 ':SP75' + cabbrev vs33 ':VS33' + cabbrev vs66 ':VS66' + cabbrev sp33 ':SP33' + cabbrev sp66 ':SP66' cabbrev diff vertical diffsplit cabbrev sudow SudoWrite cabbrev wsudo SudoWrite @@ -414,11 +414,11 @@ nmap { ':wincmd R' nmap } ':wincmd r' nmap ] ':vs' - nmap 0 ':VS25' - nmap ) ':VS75' + nmap 0 ':VS33' + nmap ) ':VS66' nmap [ ':sp:wincmd j' - nmap 9 ':SP25' - nmap ( ':SP75' + nmap 9 ':SP33' + nmap ( ':SP66' "} "DISPLAY:{ diff --git a/vim/config/settings.vim b/vim/config/settings.vim index 642162a..244189f 100644 --- a/vim/config/settings.vim +++ b/vim/config/settings.vim @@ -85,50 +85,54 @@ set timeout timeoutlen=500 "how long before timing out for mappings set ttimeout ttimeoutlen=100 "how long before timing out for terminal key codes - if has('autocmd') - "enable the auto-creation of missing folders in a save path - if !exists('*s:MakeNewDir') - function s:MakeNewDir(fullpath, buf) - if empty(getbufvar(a:buf,'&buftype')) && a:fullpath!~#'\v^\w+\:\/' - let dirpath=fnamemodify(a:fullpath,':h') - if !isdirectory(dirpath)|call mkdir(dirpath,'p')|endif - endif - endfunction - augroup WriteDir + "FUNCTIONS: {{{ + if has('autocmd') + "enable the auto-creation of missing folders in a save path + if !exists('*s:MakeNewDir') + function s:MakeNewDir(fullpath, buf) + if empty(getbufvar(a:buf,'&buftype')) && a:fullpath!~#'\v^\w+\:\/' + let dirpath=fnamemodify(a:fullpath,':h') + if !isdirectory(dirpath)|call mkdir(dirpath,'p')|endif + endif + endfunction + augroup WriteDir + autocmd! + autocmd BufWritePre * :call s:MakeNewDir(expand(''),+expand('')) + augroup END + endif + + "update the current filetype when a file is renamed + augroup RenameCheckFiletype autocmd! - autocmd BufWritePre * :call s:MakeNewDir(expand(''),+expand('')) + autocmd BufFilePost * filetype detect augroup END endif - "update the current filetype when a file is renamed - augroup RenameCheckFiletype - autocmd! - autocmd BufFilePost * filetype detect - augroup END - endif + "functions to create a split using 33% and 66% of the height + function s:SPResize33() + sp|wincmd =|q + endfunction + function s:sp33() + sp|call s:SPResize33()|wincmd j + endfunction + command! -buffer SP33 call s:sp33() + function s:sp66() + sp|wincmd j|call s:SPResize33() + endfunction + command! -buffer SP66 call s:sp66() - function s:VSResize75() - vs|wincmd =|q - endfunction - function s:vs75() - vs|call s:VSResize75() - endfunction - command! -buffer VS75 call s:vs75() - function s:vs25() - vs|wincmd h|call s:VSResize75()|wincmd l - endfunction - command! -buffer VS25 call s:vs25() - - function s:SPResize25() - sp|wincmd =|q - endfunction - function s:sp25() - sp|call s:SPResize25()|wincmd j - endfunction - command! -buffer SP25 call s:sp25() - function s:sp75() - sp|wincmd j|call s:SPResize25() - endfunction - command! -buffer SP75 call s:sp75() + "functions to create a vertical split using 33% and 66% width + function s:VSResize66() + vs|wincmd =|q + endfunction + function s:vs66() + vs|call s:VSResize66() + endfunction + command! -buffer VS66 call s:vs66() + function s:vs33() + vs|wincmd h|call s:VSResize66()|wincmd l + endfunction + command! -buffer VS33 call s:vs33() + "}}} "}}} "}}}