" These commands create the option window.
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2020 Jun 02
" If there already is an option window, jump to that one.
let buf = bufnr('option-window')
if buf >= 0
let winids = win_findbuf(buf)
if len(winids) > 0
if win_gotoid(winids[0]) == 1
finish
endif
endif
endif
" Make sure the '<' flag is not included in 'cpoptions', otherwise <CR> would
" not be recognized. See ":help 'cpoptions'".
let s:cpo_save = &cpo
set cpo&vim
" function to be called when <CR> is hit in the option-window
fun! <SID>CR()
" If on a continued comment line, go back to the first comment line
let lnum = search("^[^\t]", 'bWcn')
let line = getline(lnum)
" <CR> on a "set" line executes the option line
if match(line, "^ \tset ") >= 0
" For a local option: go to the previous window
" If this is a help window, go to the window below it
let thiswin = winnr()
let local = <SID>Find(lnum)
if local >= 0
exe line
call <SID>Update(lnum, line, local, thiswin)
endif
" <CR> on a "option" line shows help for that option
elseif match(line, "^[a-z]") >= 0
let name = substitute(line, '\([^\t]*\).*', '\1', "")
exe "help '" . name . "'"
" <CR> on an index line jumps to the group
elseif match(line, '^ \=[0-9]') >= 0
exe "norm! /" . line . "\<CR>zt"
endif
endfun
" function to be called when <Space> is hit in the option-window
fun! <SID>Space()
let lnum = line(".")
let line = getline(lnum)
" <Space> on a "set" line refreshes the option line
if match(line, "^ \tset ") >= 0
" For a local option: go to the previous window
" If this is a help window, go to the window below it
let thiswin = winnr()
let local = <SID>Fi