VIM: display custom reference bar on top of window
I would like to set up a vim environment for basic HTML edit to be used by someone else. For this I'd like to set up a quick reference bar to be shown on top of the window with things like
| <F1> | <F2> | <F3> | ...
| <br /> | 开发者_StackOverflow社区 <hr /> | bold | ...
and so on. Can this be done?
You can use additional window with scratch buffer to show things like this.
Here is prototype of the plugin. Just run the following with :so
or put this into some file inside
~/.vim/plugin
directory
function! s:set_as_scratch_buffer()
setlocal noswapfile
setlocal nomodifiable
setlocal bufhidden=delete
setlocal buftype=nofile
setlocal nobuflisted
setlocal nonumber
setlocal nowrap
setlocal cursorline
endfunction
function! s:activate_window_by_buffer_name(name)
for i in range(1, winnr('$'))
let name = bufname(winbufnr(i))
let full_name = fnamemodify(bufname(winbufnr(i)), ':p')
if name == a:name || full_name == a:name
exec i.'wincmd w'
return 1
endif
endfor
return 0
endfunction
let s:help_window_name = 'HTML\ help'
function! s:show_help()
let current_name = fnamemodify(@%, ':p')
if ! s:activate_window_by_buffer_name(s:help_window_name)
exec 'top 5 split '.s:help_window_name
call s:set_as_scratch_buffer()
endif
setlocal modifiable
let help_lines = ['line1', 'line2']
call setline(1, help_lines)
setlocal nomodifiable
call s:activate_window_by_buffer_name(current_name)
endfunction
command! -nargs=0 HtmlHelp call s:show_help()
au! BufRead,BufNewFile *.html call s:show_help()
精彩评论