runtime/pack/dist/opt/editorconfig/doc/editorconfig.txt \
runtime/pack/dist/opt/editorconfig/ftdetect/editorconfig.vim \
runtime/pack/dist/opt/editorconfig/plugin/editorconfig.vim \
+ runtime/pack/dist/opt/helpcurwin/autoload/helpcurwin.vim \
+ runtime/pack/dist/opt/helpcurwin/doc/helpcurwin.txt \
+ runtime/pack/dist/opt/helpcurwin/doc/tags \
+ runtime/pack/dist/opt/helpcurwin/plugin/helpcurwin.vim \
runtime/pack/dist/opt/helptoc/autoload/helptoc.vim \
runtime/pack/dist/opt/helptoc/doc/helptoc.txt \
runtime/pack/dist/opt/helptoc/doc/tags \
-*helphelp.txt* For Vim version 9.1. Last change: 2025 Nov 09
+*helphelp.txt* For Vim version 9.1. Last change: 2025 Dec 02
VIM REFERENCE MANUAL by Bram Moolenaar
will be opened. Otherwise the specified tag is searched for in all "doc/tags"
files in the directories specified in the 'runtimepath' option.
-If you would like to open the help in the current window, see this tip:
-|help-curwin|.
-
The initial height of the help window can be set with the 'helpheight' option
(default 20).
+
+If you want to open help on {subject} in the current window, the helpcurwin
+optional package can be used. See |package-helpcurwin|.
+
*help-buffer-options*
When the help buffer is created, several local options are set to make sure
the help text is displayed as it was intended:
help-TOC helphelp.txt /*help-TOC*
help-buffer-options helphelp.txt /*help-buffer-options*
help-context help.txt /*help-context*
-help-curwin tips.txt /*help-curwin*
help-notation helphelp.txt /*help-notation*
help-summary usr_02.txt /*help-summary*
help-tags tags 1
package-doc repeat.txt /*package-doc*
package-documentation repeat.txt /*package-documentation*
package-editorconfig usr_05.txt /*package-editorconfig*
+package-helpcurwin tips.txt /*package-helpcurwin*
package-helptoc helphelp.txt /*package-helptoc*
package-hlyank usr_05.txt /*package-hlyank*
package-justify usr_25.txt /*package-justify*
-*tips.txt* For Vim version 9.1. Last change: 2025 Nov 09
+*tips.txt* For Vim version 9.1. Last change: 2025 Dec 02
VIM REFERENCE MANUAL by Bram Moolenaar
Hex editing |hex-editing|
Using <> notation in autocommands |autocmd-<>|
Highlighting matching parens |match-parens|
-Opening help in the current window |help-curwin|
+Opening help in the current window |package-helpcurwin|
==============================================================================
Editing C programs *C-editing*
<
==============================================================================
-Opening help in the current window *help-curwin*
+Opening help in the current window *package-helpcurwin*
-By default, help is displayed in a split window. If you prefer it opens in
-the current window, try this custom `:HelpCurwin` command:
->
- command -bar -nargs=? -complete=help HelpCurwin execute s:HelpCurwin(<q-args>)
- let s:did_open_help = v:false
-
- function s:HelpCurwin(subject) abort
- let mods = 'silent noautocmd keepalt'
- if !s:did_open_help
- execute mods .. ' help'
- execute mods .. ' helpclose'
- let s:did_open_help = v:true
- endif
- if !getcompletion(a:subject, 'help')->empty()
- execute mods .. ' edit ' .. &helpfile
- set buftype=help
- endif
- return 'help ' .. a:subject
- endfunction
-<
+By default, help is displayed in a split window. In some scenarios, you may
+prefer to open the help in the current window. The optional helpcurwin
+package makes this possible. Load the package manually, or in your |vimrc|,
+with: >vim
+ packadd helpcurwin
+<
+After it has loaded:
+- The command `:HelpCurwin` {subject} can be used to open help in the current
+ window.
+- If the current window contains a modified buffer, the plugin asks for
+ confirmation before replacing it. If confirmed, the buffer becomes
+ hidden |hidden-buffer|.
+- The help file, |helpcurwin.txt|, will be available and describes the plugin
+ in more details.
vim:tw=78:ts=8:noet:ft=help:norl:
--- /dev/null
+vim9script
+
+# Open Vim help on {subject} in the current window (rather than a new split)
+#
+# Maintainer: The Vim Project <https://github.com/vim/vim>
+# Last change: 2025 Dec 02
+
+export def Open(subject: string): void
+
+ const HELPCURWIN: func = (): string => {
+ if !getcompletion(subject, 'help')->empty() || subject->empty()
+ if &buftype != 'help'
+ execute 'silent noautocmd keepalt enew'
+ setlocal buftype=help noswapfile
+ endif
+ endif
+ return $'help {subject}'
+ }
+
+ var contmod: bool = true
+ if &modified
+ echohl MoreMsg
+ echo $'Buffer {bufname()} is modified - continue? (y/n)'
+ echohl None
+ contmod = (getcharstr() == 'y')
+ endif
+ if contmod
+ try
+ execute HELPCURWIN()
+ catch
+ echohl Error
+ # {subject} invalid - Echo 'helpcurwin: E149:' (omit 'Vim(help):')
+ echo $'helpcurwin: {v:exception->substitute("^[^:]\+:", "", "")}'
+ echohl None
+ endtry
+ else
+ echo $'Aborted opening in current window, :help {subject}'
+ endif
+
+enddef
+
+# vim: ts=8 sts=2 sw=2 et
--- /dev/null
+*helpcurwin.txt* For Vim version 9.1. Last change: 2025 Dec 02
+
+The helpcurwin optional package enables opening help in the current window.
+
+1. :HelpCurwin |helpcurwin-command|
+2. helpcurwin#Open() |helpcurwin-function|
+3. <Plug>HelpCurwin; |helpcurwin-mapping|
+
+
+==============================================================================
+1. :HelpCurwin *:HelpCurwin* *helpcurwin-command*
+
+:HelpCurwin Use the current window to display the help file,
+ |help.txt| in read-only mode. It leaves any other
+ windows as-is (including when there is another
+ help window(s)).
+
+:HelpCurwin {subject} Like ":HelpCurwin" but, additionally open the
+ applicable help file at the tag {subject}.
+ For example: >
+
+ :HelpCurwin version9.2
+<
+ It should otherwise behave like :help {subject}.
+
+You may also want to save typing with a command line abbreviation,
+for example: >vi
+
+ cnoreabbrev <expr> hc getcmdtype() == ":" &&
+ \ getcmdline() == 'hc' ? 'HelpCurwin' : 'hc'
+<
+
+==============================================================================
+2. helpcurwin#Open() *helpcurwin-function*
+
+The underlying `:def` function may also be used, for example: >vim
+
+ :vim9cmd helpcurwin#Open('version9.2')
+<
+This may be useful from other scripts where you want to bring up help on
+{subject} in the current window.
+
+
+==============================================================================
+3. <Plug>HelpCurwin; *helpcurwin-mapping*
+
+There may be times when you want to get the help for a WORD, such as when it
+is in a Vim9 script. If you want to open it in the same window, you can map
+<Plug>HelpCurwin; to keys of your choosing to enable that. For example: >vim9
+
+ nnoremap <Leader>hc <Plug>HelpCurwin;
+
+Once sourced (in this instance, when <Leader>hc is typed), the applicable
+help file will be opened in the current window at the tag for <cWORD> (that
+is, the |WORD| under the cursor), if it exists.
+
+
+==============================================================================
+ vim:tw=78:ts=8:noet:ft=help:norl:
--- /dev/null
+:HelpCurwin helpcurwin.txt /*:HelpCurwin*
+helpcurwin-command helpcurwin.txt /*helpcurwin-command*
+helpcurwin-function helpcurwin.txt /*helpcurwin-function*
+helpcurwin-mapping helpcurwin.txt /*helpcurwin-mapping*
+helpcurwin.txt helpcurwin.txt /*helpcurwin.txt*
--- /dev/null
+vim9script
+
+# Open Vim help on {subject} in the current window (rather than a new split)
+#
+# Maintainer: The Vim Project <https://github.com/vim/vim>
+# Last change: 2025 Dec 02
+
+# Exit when the helpcurwin plugin is loaded already
+if exists('g:loaded_helpcurwin')
+ finish
+endif
+g:loaded_helpcurwin = true
+
+import autoload 'helpcurwin.vim'
+
+command -bar -nargs=? -complete=help HelpCurwin helpcurwin.Open(<q-args>)
+
+nnoremap <Plug>HelpCurwin; <ScriptCmd>helpcurwin.Open(expand('<cWORD>'))<CR>
+
+# vim: ts=8 sts=2 sw=2 et
test_perl \
test_plugin_comment \
test_plugin_glvs \
+ test_plugin_helpcurwin \
test_plugin_helptoc \
test_plugin_man \
test_plugin_matchparen \
test_perl.res \
test_plugin_comment.res \
test_plugin_glvs.res \
+ test_plugin_helpcurwin.res \
test_plugin_helptoc.res \
test_plugin_man.res \
test_plugin_matchparen.res \
--- /dev/null
+" Test for the HelpCurwin package
+
+func Test_helpcurwin_1()
+ packadd helpcurwin
+ call assert_equal(2, exists(':HelpCurwin'))
+ new Xfoobar.txt
+ only
+ HelpCurwin tips.txt
+ call assert_match('.*tips.txt', bufname('%'))
+ call assert_equal(1, winnr('$'))
+ call assert_true(bufexists('Xfoobar.txt'))
+ %bw
+endfunc
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1946,
/**/
1945,
/**/