Detecting 'view'

37 views
Skip to first unread message

Paul

unread,
Oct 6, 2012, 6:47:41 AM10/6/12
to vim...@googlegroups.com
In .vimrc, how can I detect whether vim was invoked as 'view'? Looking for &readonly also matched when doing :help from within 'vim', which I don't want, eg:

if &readonly
" Things that should only happen when called as 'view'
endif

--

.

Christian Brabandt

unread,
Oct 6, 2012, 7:01:17 AM10/6/12
to vim...@googlegroups.com
Hi Paul!

On Sa, 06 Okt 2012, Paul wrote:

> In .vimrc, how can I detect whether vim was invoked as 'view'? Looking
> for &readonly also matched when doing :help from within 'vim', which I
> don't want, eg:

:h v:progname

Mit freundlichen Gr��en
Christian
--
Seit die Mathematiker �ber die Relativit�tstheorie hergefallen sind,
verstehe ich sie selbst nicht mehr.
-- Albert Einstein

Tony Mechelynck

unread,
Oct 7, 2012, 3:27:29 AM10/7/12
to vim...@googlegroups.com
On 06/10/12 13:01, Christian Brabandt wrote:
> Hi Paul!
>
> On Sa, 06 Okt 2012, Paul wrote:
>
>> In .vimrc, how can I detect whether vim was invoked as 'view'? Looking
>> for &readonly also matched when doing :help from within 'vim', which I
>> don't want, eg:
>
> :h v:progname
>
> Mit freundlichen Gr��en
> Christian
>

You (Paul) may want to test against a regaxp, e.g.

if v:progname =~ 'view'

in order to catch gview, rview, or "view with any additional trailing
characters" (which Vim will treat as invoking it as view).


Best regards,
Tony.
--
LAUNCELOT: I am, sir. I am a Knight of King Arthur.
FATHER: 'Mm ... very nice castle, Camelot ... very good pig country....
"Monty Python and the Holy Grail" PYTHON (MONTY)
PICTURES LTD

Paul

unread,
Oct 8, 2012, 6:52:21 AM10/8/12
to vim...@googlegroups.com
Excellent! Thanks, Christian and Tony.

--

.
Reply all
Reply to author
Forward
0 new messages