Auto folding, numbers, and preview fixups
This commit is contained in:
parent
799e273ec6
commit
b1e3429cee
1 changed files with 42 additions and 22 deletions
64
.vimrc
64
.vimrc
|
|
@ -17,8 +17,13 @@ set fenc=utf-8
|
||||||
if exists('&t_SI')
|
if exists('&t_SI')
|
||||||
let &t_SI = "\<Esc>]12;lightgoldenrod\x7"
|
let &t_SI = "\<Esc>]12;lightgoldenrod\x7"
|
||||||
let &t_EI = "\<Esc>]12;green\x7"
|
let &t_EI = "\<Esc>]12;green\x7"
|
||||||
|
elseif has("gui")
|
||||||
|
set guicursor=n-v-c:block-Cursor/lCursor,ve:ver35-Cursor,o:hor50-Cursor,i-ci:ver25-Cursor/lCursor,r-cr:hor20-Cursor/lCursor,sm:block-Cursor-blinkwait175-blinkoff150-blinkon175
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" Clear autocommands for re-sourceing
|
||||||
|
autocmd!
|
||||||
|
|
||||||
"-----------------------------------------------------------------------
|
"-----------------------------------------------------------------------
|
||||||
" settings
|
" settings
|
||||||
"-----------------------------------------------------------------------
|
"-----------------------------------------------------------------------
|
||||||
|
|
@ -100,13 +105,13 @@ endif
|
||||||
set virtualedit=block
|
set virtualedit=block
|
||||||
|
|
||||||
" Set our fonts
|
" Set our fonts
|
||||||
if has("gui_kde")
|
"if has("gui_kde")
|
||||||
set guifont=Terminus/12/-1/5/50/0/0/0/0/0
|
" set guifont=Terminus/12/-1/5/50/0/0/0/0/0
|
||||||
elseif has("gui_gtk")
|
"elseif has("gui_gtk")
|
||||||
set guifont=Terminus\ 12
|
" set guifont=Terminus\ 12
|
||||||
elseif has("gui_running")
|
"elseif has("gui_running")
|
||||||
set guifont=-xos4-terminus-medium-r-normal--12-140-72-72-c-80-iso8859-1
|
" set guifont=-xos4-terminus-medium-r-normal--12-140-72-72-c-80-iso8859-1
|
||||||
endif
|
"endif
|
||||||
|
|
||||||
" Try to load a nice colourscheme
|
" Try to load a nice colourscheme
|
||||||
if ! has("gui_running")
|
if ! has("gui_running")
|
||||||
|
|
@ -153,7 +158,7 @@ if has("folding")
|
||||||
endfun
|
endfun
|
||||||
command! Tfdm call ToggleFoldmethod()
|
command! Tfdm call ToggleFoldmethod()
|
||||||
set foldenable
|
set foldenable
|
||||||
set foldmethod=marker
|
set foldmethod=syntax
|
||||||
set foldlevelstart=99
|
set foldlevelstart=99
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
@ -296,14 +301,24 @@ set fillchars=fold:-
|
||||||
"-----------------------------------------------------------------------
|
"-----------------------------------------------------------------------
|
||||||
" Preview window for :help CursorHold-example after updatetime
|
" Preview window for :help CursorHold-example after updatetime
|
||||||
"-----------------------------------------------------------------------
|
"-----------------------------------------------------------------------
|
||||||
au! CursorHold *.[ch] nested call PreviewWord()
|
|
||||||
func PreviewWord()
|
au CursorHold *.[ch] nested call PreviewWord()
|
||||||
|
au CursorMoved *.[ch] nested call UnPreviewWord()
|
||||||
|
fun! UnPreviewWord()
|
||||||
|
if &previewwindow
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
pclose
|
||||||
|
endfun
|
||||||
|
fun! PreviewWord()
|
||||||
if &previewwindow " don't do this in the preview window
|
if &previewwindow " don't do this in the preview window
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
if &lines < 40 " not for small terminals
|
||||||
|
return
|
||||||
|
endif
|
||||||
let w = expand("<cword>") " get the word under cursor
|
let w = expand("<cword>") " get the word under cursor
|
||||||
if w =~ '\a' " if the word contains a letter
|
if w =~ '\a' " if the word contains a letter
|
||||||
|
|
||||||
" Delete any existing highlight before showing another tag
|
" Delete any existing highlight before showing another tag
|
||||||
silent! wincmd P " jump to preview window
|
silent! wincmd P " jump to preview window
|
||||||
if &previewwindow " if we really get there...
|
if &previewwindow " if we really get there...
|
||||||
|
|
@ -320,7 +335,7 @@ func PreviewWord()
|
||||||
|
|
||||||
silent! wincmd P " jump to preview window
|
silent! wincmd P " jump to preview window
|
||||||
if &previewwindow " if we really get there...
|
if &previewwindow " if we really get there...
|
||||||
exe "wincmd J"
|
" exe "wincmd J" " make the window appear below
|
||||||
if has("folding")
|
if has("folding")
|
||||||
silent! .foldopen " don't want a closed fold
|
silent! .foldopen " don't want a closed fold
|
||||||
endif
|
endif
|
||||||
|
|
@ -330,6 +345,7 @@ func PreviewWord()
|
||||||
" Add a match highlight to the word at this position
|
" Add a match highlight to the word at this position
|
||||||
hi previewWord term=bold cterm=underline gui=underline
|
hi previewWord term=bold cterm=underline gui=underline
|
||||||
exe 'match previewWord "\%' . line(".") . 'l\%' . col(".") . 'c\k*"'
|
exe 'match previewWord "\%' . line(".") . 'l\%' . col(".") . 'c\k*"'
|
||||||
|
" exe "normal " . &previewheight / 2 . "j"
|
||||||
wincmd p " back to old window
|
wincmd p " back to old window
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
@ -357,17 +373,21 @@ set dictionary=/usr/share/dict/words
|
||||||
if has("eval")
|
if has("eval")
|
||||||
" If we're in a wide window, enable line numbers.
|
" If we're in a wide window, enable line numbers.
|
||||||
fun! <SID>WindowWidth()
|
fun! <SID>WindowWidth()
|
||||||
if winwidth(0) > 90
|
if winwidth(0) >= 76 " 72 + 4
|
||||||
setlocal foldcolumn=1
|
setlocal foldcolumn=1
|
||||||
setlocal number
|
setlocal relativenumber
|
||||||
else
|
else
|
||||||
setlocal nonumber
|
setlocal norelativenumber
|
||||||
setlocal foldcolumn=0
|
setlocal foldcolumn=0
|
||||||
endif
|
endif
|
||||||
endfun
|
endfun
|
||||||
autocmd VimEnter * :call <SID>WindowWidth()
|
autocmd VimEnter,WinEnter * :call <SID>WindowWidth()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" Show the column and line of the cursor
|
||||||
|
au VimEnter,BufEnter,WinEnter * set cursorcolumn " cursorline
|
||||||
|
au WinLeave * set nocursorcolumn " nocursorline
|
||||||
|
|
||||||
" content creation
|
" content creation
|
||||||
if has("autocmd")
|
if has("autocmd")
|
||||||
augroup puppet
|
augroup puppet
|
||||||
|
|
@ -514,7 +534,7 @@ if has("autocmd")
|
||||||
" if we have a vim which supports QuickFixCmdPost (vim7),
|
" if we have a vim which supports QuickFixCmdPost (vim7),
|
||||||
" give us an error window after running make, grep etc, but
|
" give us an error window after running make, grep etc, but
|
||||||
" only if results are available.
|
" only if results are available.
|
||||||
autocmd QuickFixCmdPost * botright cwindow 5
|
autocmd QuickFixCmdPost * botright cwindow 6
|
||||||
|
|
||||||
autocmd QuickFixCmdPre make
|
autocmd QuickFixCmdPre make
|
||||||
\ let g:make_start_time=localtime()
|
\ let g:make_start_time=localtime()
|
||||||
|
|
@ -608,11 +628,11 @@ if has("eval")
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" quickfix things
|
" quickfix things
|
||||||
nmap <Leader>cwc :cclose<CR>
|
"nmap <Leader>cwc :cclose<CR>
|
||||||
nmap <Leader>cwo :botright copen 5<CR><C-w>p
|
"nmap <Leader>cwo :botright copen 5<CR><C-w>p
|
||||||
nmap <Leader>cn :cnext<CR>
|
"nmap <Leader>cn :cnext<CR>
|
||||||
nmap - :cnext<CR>
|
nmap - :cnext<CR>
|
||||||
nmap <Leader>cp :cprevious<CR>
|
"nmap <Leader>cp :cprevious<CR>
|
||||||
|
|
||||||
" Annoying default mappings
|
" Annoying default mappings
|
||||||
inoremap <S-Up> <C-o>gk
|
inoremap <S-Up> <C-o>gk
|
||||||
|
|
@ -681,7 +701,7 @@ noremap <Leader>gq gggqG
|
||||||
noremap <Leader>gp gqap
|
noremap <Leader>gp gqap
|
||||||
|
|
||||||
" Clear lines
|
" Clear lines
|
||||||
noremap <Leader>clr :s/^.*$//<CR>:nohls<CR>
|
"noremap <Leader>clr :s/^.*$//<CR>:nohls<CR>
|
||||||
|
|
||||||
" Delete blank lines
|
" Delete blank lines
|
||||||
noremap <Leader>dbl :g/^$/d<CR>:nohls<CR>
|
noremap <Leader>dbl :g/^$/d<CR>:nohls<CR>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue