On 09/06/11 09:56, Asis Hallab wrote:
Dear Vimers,

How do I do something like the following:
"
if(defined(tags))
   return "\<c-x>\<c-]>"
endif
"
The tags-variable is the one set by :set tags="./tags".

How do I get the above to work?

Many thanks in advance!
Asis
[...]

see :help exists()

if !exists('+tags') || &tags == ""
        " !                     logical NOT
        " exists('+tags')       compiled-in and works
        " ||                    logical OR
        " &tags                 the value of the 'tags' option
        " == ""                 is set to the empty string
        " meaning: «if empty or not compiled-in»
        " -- we test first for compiled-in
        "    because of short-circuit evaluation
        " NOTE: the empty string is NOT the default value
        "       of the 'tags' option
endif

if exists('foobar')
        echo 'foobar is defined as' foobar
else
        echo 'foobar is undefined'
endif

if exists(':MySpecialCommand') == 2
        echo ':MySpecialCommand is defined, as follows:'
        verbose command MySpecialCommand
else
        echo ':MySpecialCommand is undefined'
endif

if exists('*MySpecialFunc')
        echo 'MySpecialFunc() is defined, as follows:'
        verbose func MySpecialFunc
else
        echo 'MySpecialFunc() is undefined'
endif

etc.


Best regards,
Tony.
--
Fine day to throw a party.  Throw him as far as you can.

--
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

Reply via email to