|
Hello
according to ':h exists()' we can use 'exists("##ColorScheme")' to check for the availability of an colorscheme. :colorscheme desert :echo exists("##desert") 0 ,----[ :h exists() ]------------------------ exists({expr}) The result is a Number, which is non-zero if {expr} is defined, zero otherwise. `--------------------------------------------- I am pretty sure this used to work somewhen. Is this a bug or am i doing s.th. wrong? -- Regards, Thilo 4096R/0xC70B1A8F 721B 1BA0 095C 1ABA 3FC6 7C18 89A4 A2A0 C70B 1A8F -- 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 |
|
Hi Thilo!
On So, 03 Jun 2012, Thilo Six wrote: > according to ':h exists()' we can use 'exists("##ColorScheme")' to check for the > availability of an colorscheme. > > :colorscheme > desert > :echo exists("##desert") > 0 > > > ,----[ :h exists() ]------------------------ > > exists({expr}) The result is a Number, which is non-zero if > {expr} is defined, zero otherwise. > `--------------------------------------------- > > I am pretty sure this used to work somewhen. Is this a bug or am i doing s.th. > wrong? You are not supposed to test a specific ColorScheme, rather whether an event for an autocommand is supported, e.g. exist("##FileType") echoes 1, if your Vim supports the FileType autocommand. regards, Christian -- Drinnen ist es genauso wie draußen, nur anders. -- 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 |
|
Hello Christian,
Excerpt from Christian Brabandt: > Hi Thilo! > > On So, 03 Jun 2012, Thilo Six wrote: > >> according to ':h exists()' we can use 'exists("##ColorScheme")' to check for the >> availability of an colorscheme. >> >> :colorscheme >> desert >> :echo exists("##desert") >> 0 >> >> >> ,----[ :h exists() ]------------------------ >> >> exists({expr}) The result is a Number, which is non-zero if >> {expr} is defined, zero otherwise. >> `--------------------------------------------- >> >> I am pretty sure this used to work somewhen. Is this a bug or am i doing s.th. >> wrong? > > You are not supposed to test a specific ColorScheme, rather whether an > event for an autocommand is supported, e.g. exist("##FileType") echoes > 1, if your Vim supports the FileType autocommand. Then the 'Examples:' section below ':h exists()' needs to be updated. > > regards, > Christian -- Regards, Thilo 4096R/0xC70B1A8F 721B 1BA0 095C 1ABA 3FC6 7C18 89A4 A2A0 C70B 1A8F -- 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 |
|
Hi Thilo!
On So, 03 Jun 2012, Thilo Six wrote: > Hello Christian, > > > Excerpt from Christian Brabandt: > > > Hi Thilo! > > > > On So, 03 Jun 2012, Thilo Six wrote: > > > >> according to ':h exists()' we can use 'exists("##ColorScheme")' to check for the > >> availability of an colorscheme. > >> > >> :colorscheme > >> desert > >> :echo exists("##desert") > >> 0 > >> > >> > >> ,----[ :h exists() ]------------------------ > >> > >> exists({expr}) The result is a Number, which is non-zero if > >> {expr} is defined, zero otherwise. > >> `--------------------------------------------- > >> > >> I am pretty sure this used to work somewhen. Is this a bug or am i doing s.th. > >> wrong? > > > > You are not supposed to test a specific ColorScheme, rather whether an > > event for an autocommand is supported, e.g. exist("##FileType") echoes > > 1, if your Vim supports the FileType autocommand. > > Then the 'Examples:' section below ':h exists()' needs to be updated. Well, ColorScheme is a valid autocmd event. regards, Christian -- -- 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 |
|
Hello Christian,
Excerpt from Christian Brabandt: -- <snip> -- > Well, ColorScheme is a valid autocmd event. Yes that last mail was fired to fast. Thank you for correcting me. Then is there a possibility to check for the availability of an colorscheme other then 'filereadable(expand(expand("~/.vim/colors/desert.vim")))' ? > > regards, > Christian -- Regards, Thilo 4096R/0xC70B1A8F 721B 1BA0 095C 1ABA 3FC6 7C18 89A4 A2A0 C70B 1A8F -- 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 |
|
Hi Thilo!
On So, 03 Jun 2012, Thilo Six wrote: > Then is there a possibility to check for the availability of an colorscheme > other then 'filereadable(expand(expand("~/.vim/colors/desert.vim")))' ? Well, this should also work: echo globpath(&rtp, 'colors/desert.vim') regards, Christian -- 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 |
|
Hello Christian,
Excerpt from Christian Brabandt: -- <snip> -- >> Then is there a possibility to check for the availability of an colorscheme >> other then 'filereadable(expand(expand("~/.vim/colors/desert.vim")))' ? > > Well, this should also work: > > echo globpath(&rtp, 'colors/desert.vim') :echo globpath(&rtp, 'colors/desert.vim') /home/$USER/.vim/colors/desert.vim /usr/share/vim/vim73/colors/desert.vim However: :if globpath(&rtp, 'colors/desert.vim') | echo "yes" | else | echo "no" | endif no I probably could write a function that ':ru colors/desert.vim' and then checks for 'g:colors_name' being set to a specific value. The bad about this would be it adds additional seeks of the runtimepath which i expect to be more expensive then the above version. Therefor i stick with the above solution. Thank you Christian nevertheless. > > regards, > Christian > -- Regards, Thilo 4096R/0xC70B1A8F 721B 1BA0 095C 1ABA 3FC6 7C18 89A4 A2A0 C70B 1A8F -- 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 |
|
Hi Thilo!
On So, 03 Jun 2012, Thilo Six wrote: > :if globpath(&rtp, 'colors/desert.vim') | echo "yes" | else | echo "no" | endif > no Yeah, it returns several matches. Better would be: :if len(globpath(&rtp, 'colors/desert.vim')) | echo "yes" | else | echo "no" | endif yes regards, Christian -- 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 |
|
On Sunday, June 3, 2012 10:24:29 AM UTC-5, Christian Brabandt wrote:
> Hi Thilo! > > On So, 03 Jun 2012, Thilo Six wrote: > > > :if globpath(&rtp, 'colors/desert.vim') | echo "yes" | else | echo "no" | endif > > no > > Yeah, it returns several matches. Better would be: > > :if len(globpath(&rtp, 'colors/desert.vim')) | echo "yes" | else | echo "no" | endif > yes > What about the empty() function, for clarity and speed? empty({expr}) *empty()* Return the Number 1 if {expr} is empty, zero otherwise. A |List| or |Dictionary| is empty when it does not have any items. A Number is empty when its value is zero. For a long |List| this is much faster than comparing the length with zero. -- 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 |
|
On Mon, June 4, 2012 06:17, Ben Fritz wrote:
> On Sunday, June 3, 2012 10:24:29 AM UTC-5, Christian Brabandt wrote: >> :if len(globpath(&rtp, 'colors/desert.vim')) | echo "yes" | else | echo >> "no" | endif > > What about the empty() function, for clarity and speed? > Yes, that is better. regards, Christian -- 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 |
|
In reply to this post by Thilo Six
Hello folks,
Hello Christian, -- <snip> -- > Then is there a possibility to check for the availability of an colorscheme > other then 'filereadable(expand(expand("~/.vim/colors/desert.vim")))' ? Just for the record: What i have been looking for is actually documented below ':h :verbose'. -- Regards, Thilo 4096R/0xC70B1A8F 721B 1BA0 095C 1ABA 3FC6 7C18 89A4 A2A0 C70B 1A8F -- 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 |
| Powered by Nabble | Edit this page |
