Sunday, April 1, 2012

Re: :help WITHOUT split screen

On 30/03/12 15:35, Tarlika Elisabeth Schmitz wrote:
> On Fri, 30 Mar 2012 14:39:33 +0200
> Guido Van Hoecke <guivho@gmail.com> wrote:
>
>>> Is there a way to prevent :help from splitting the window?!
>> cabbrev h tab help
>
> Many thanks - works fine here.
>
> I've covered all options in .vimrc now:
>
> " always open help in new tab
> cabbrev help tab help
> cabbrev he tab help
> cabbrev h tab help
>
>
>
>
>


One slight disadvantage of the above (which can be worked around in
recent versions) is that if you ever type the word "help" on a command
lne, it will be abbreviated even if not at the start. For example, the
(very useful) command

:help help

will become

:tab help tab help

which not only is not what you want, it is illegal. In addition, the
abbreviation will be triggered also in / or ? (search) command-lines,
which you don't want either.

The way to work around it is as follows:

if version < 700
cnoreabbrev h tab h
cnoreabbrev he tab he
cnoreabbrev hel tab hel
cnoreabbrev help tab help
" in Vim 6.x or earlier (which is now obsolete
" but hasn't got :abbr <expr> )
" we'll need to break the abbrev halfway
" (e.g. by <Left><Right>)
" to avoid expanding the argument of :help help
" or h he hel help in a search command
else
cnoreabbrev <expr> h
\ ((getcmdtype() == ':' && getcmdpos() <= 2)?
\ 'tab h' : 'h')
cnoreabbrev <expr> he
\ ((getcmdtype() == ':' && getcmdpos() <= 3)?
\ 'tab he' : 'he')
cnoreabbrev <expr> hel
\ ((getcmdtype() == ':' && getcmdpos() <= 4)?
\ 'tab hel' : 'hel')
cnoreabbrev <expr> help
\ ((getcmdtype() == ':' && getcmdpos() <= 5)?
\ 'tab help' : 'help')
endif

Notes:
-----
- The above (meant for cut'n paste) assumes 'nocompatible', which is the
default if your vimrc is named .vimrc or _vimrc but not .exrc or _exrc
- The deprecated (but still valid) variable name "version" is used in
preference to "v:version" for compatibility with some even older
obsolete versions.


Best regards,
Tony.
--
Once Law was sitting on the bench
And Mercy knelt a-weeping.
"Clear out!" he cried, "disordered wench!
Nor come before me creeping.
Upon you knees if you appear,
'Tis plain you have no standing here."

Then Justice came. His Honor cried:
"YOUR states? -- Devil seize you!"
"Amica curiae," she replied --
"Friend of the court, so please you."
"Begone!" he shouted -- "There's the door --
I never saw your face before!"
-- Ambrose Bierce, "The Devil's Dictionary"

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: