From e88147c40c18f3a3f5ad247d65e1144db812096e Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 16 Mar 2011 21:09:24 -0700 Subject: [PATCH] Fixed annoying auto-numbering stuff. Bound to ^n --- .vimrc | 52 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/.vimrc b/.vimrc index 95df343..19094b8 100644 --- a/.vimrc +++ b/.vimrc @@ -150,7 +150,7 @@ set autoindent set smartindent inoremap # X# -" Enable folds {{{2 +" Disable folds by default; toggle with zi {{{2 if has("folding") fun! ToggleFoldmethod() if &foldmethod == "marker" @@ -160,10 +160,10 @@ if has("folding") endif endfun command! Tfdm call ToggleFoldmethod() - set foldenable + set nofoldenable set foldmethod=syntax - set foldlevelstart=99 " Start with all folds open - "set foldclose=all " Close folds when leaving them + set foldlevelstart=0 " Start with all folds closed + "set foldclose=all " Close folds when cursor leaves them endif " Syntax when printing {{{2 @@ -334,21 +334,6 @@ set dictionary=/usr/share/dict/words "----------------------------------------------------------------------- " {{{1 -" Show number and fold columns in windows {{{2 -if has("eval") - " If we're in a wide window, enable line numbers. - fun! WindowWidth() - if winwidth(0) >= 76 " 72 + 4 - setlocal foldcolumn=1 - setlocal relativenumber - else - setlocal norelativenumber - setlocal foldcolumn=0 - endif - endfun - autocmd VimEnter,WinEnter,TabEnter,BufWinEnter,BufNew * :call WindowWidth() -endif - " Show the column and/or line of the cursor {{{2 au VimEnter,BufEnter,WinEnter * set cursorcolumn " cursorline au WinLeave * set nocursorcolumn " nocursorline @@ -923,6 +908,33 @@ if has("eval") inoremap endif +" ^n Show number and fold columns in windows {{{2 +if has("eval") + function! FoldNumbers() + " If we're in a wide window, enable line numbers. + if winwidth(0) >= 76 " 72 + 4, or should I use tw? + " Add folds, or cycle through number schemes + if &foldlevel < 99 && &foldenable && &foldcolumn == 0 + setlocal foldcolumn=1 + elseif (&foldlevel == 99 || ! &foldenable) && &foldcolumn != 0 + setlocal foldcolumn=0 + elseif ! &rnu && ! &nu + setlocal relativenumber + elseif &rnu + setlocal number + elseif &nu + setlocal nonumber + endif + else + setlocal norelativenumber + setlocal nonumber + setlocal foldcolumn=0 + endif + endfun + "autocmd WinEnter,BufWinEnter,BufNew * :call FoldNumbers() + noremap :call FoldNumbers() +endif + " }}}1 "----------------------------------------------------------------------- @@ -1138,7 +1150,7 @@ map map map :vsplit ~/.vim/ref_full.vim map :11vsplit ~/.vim/ref.vim -map :Sexplore $HOME +"map :Sexplore $HOME map :2split ~/.vim/fun_ref.vim map :set rnu! map :set nu!