make URLs clickable

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

make URLs clickable

Albert Zeyer
Hi,

I want to be able to click on URLs I see in MacVim so that it opens the URL with the responsible application (e.g. a http link with my default browser). How can I do that? Is that possible?

Regards,
Albert

--
--
You received this message from the "vim_mac" 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

---
You received this message because you are subscribed to the Google Groups "vim_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: make URLs clickable

Tony Mechelynck
On Friday, November 1, 2013 9:29:03 PM UTC+1, Albert Zeyer wrote:
> Hi,
>
> I want to be able to click on URLs I see in MacVim so that it opens the URL with the responsible application (e.g. a http link with my default browser). How can I do that? Is that possible?
>
> Regards,
> Albert

A valid URL cannot include spaces (they must be replaced by %20), so if it is itself between spaces, "+yiW (with the cursor anywhere on it) will yank it to the clipboard. Similarly "+yi< or "+yi> if it is between <>, etc., see ":help object-motions". Then you can paste it into your favourite browser's URL bar.

This question (or at least this answer) applies to vim (compiled with +clipboard, of course) on any platform, not just on the Mac, so it should have been asked on the vim_use group.

Best regards,
Tony.
--
A "No" uttered from deepest conviction is better and greater than a
"Yes" merely uttered to please, or what is worse, to avoid trouble.
                -- Mahatma Gandhi

--
--
You received this message from the "vim_mac" 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

---
You received this message because you are subscribed to the Google Groups "vim_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: make URLs clickable

Albert Zeyer
On Saturday, November 2, 2013 11:52:19 AM UTC+1, Tony Mechelynck wrote:

> On Friday, November 1, 2013 9:29:03 PM UTC+1, Albert Zeyer wrote:
> > Hi,
> >
> > I want to be able to click on URLs I see in MacVim so that it opens the URL with the responsible application (e.g. a http link with my default browser). How can I do that? Is that possible?
> >
> > Regards,
> > Albert
>
> A valid URL cannot include spaces (they must be replaced by %20), so if it is itself between spaces, "+yiW (with the cursor anywhere on it) will yank it to the clipboard. Similarly "+yi< or "+yi> if it is between <>, etc., see ":help object-motions". Then you can paste it into your favourite browser's URL bar.
>
> This question (or at least this answer) applies to vim (compiled with +clipboard, of course) on any platform, not just on the Mac, so it should have been asked on the vim_use group.
>
> Best regards,
> Tony.
> --
> A "No" uttered from deepest conviction is better and greater than a
> "Yes" merely uttered to please, or what is worse, to avoid trouble.
> -- Mahatma Gandhi

Thanks for the answer.

But I really want to click on it with my mouse cursor. Also, it should not be pasted to the clipboard; I want it to open the responsible application right away automatically. As if you click a link in any other application.

This is MacVim specific, I think.

Best regards,
Albert

--
--
You received this message from the "vim_mac" 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

---
You received this message because you are subscribed to the Google Groups "vim_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: make URLs clickable

Sylvain Soliman-2
    Hi,

* Albert Zeyer <[hidden email]>:
> But I really want to click on it with my mouse cursor. Also, it should not be pasted to the clipboard; I want it to open the responsible application right away automatically. As if you click a link in any other application.
>
> This is MacVim specific, I think.

Something similar can be obtained by running MacVim inside iTerm2 and then
use the fact that cmd-click in iTerm2 opens a filename/URL (I think this is
the default behavior, at least it can be configured that way).

        Sylvain Soliman

--
Sylvain Soliman <[hidden email]>   GnuPG Public Key: 0x0F53AF99
Page personnelle                   http://contraintes.inria.fr/~soliman/

smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: make URLs clickable

Albert Zeyer
On Sat, Nov 2, 2013 at 4:38 PM, Sylvain Soliman <[hidden email]> wrote:

>     Hi,
>
> * Albert Zeyer <[hidden email]>:
>> But I really want to click on it with my mouse cursor. Also, it should not be pasted to the clipboard; I want it to open the responsible application right away automatically. As if you click a link in any other application.
>>
>> This is MacVim specific, I think.
>
> Something similar can be obtained by running MacVim inside iTerm2 and then
> use the fact that cmd-click in iTerm2 opens a filename/URL (I think this is
> the default behavior, at least it can be configured that way).


Yea (also works with standard Vim in standard Terminal), but I want to
run it in graphical mode as a real app.

--
--
You received this message from the "vim_mac" 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

---
You received this message because you are subscribed to the Google Groups "vim_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: make URLs clickable

Tony Mechelynck
In reply to this post by Albert Zeyer
On Saturday, November 2, 2013 3:42:14 PM UTC+1, Albert Zeyer wrote:

> On Saturday, November 2, 2013 11:52:19 AM UTC+1, Tony Mechelynck wrote:
> > On Friday, November 1, 2013 9:29:03 PM UTC+1, Albert Zeyer wrote:
> > > Hi,
> > >
> > > I want to be able to click on URLs I see in MacVim so that it opens the URL with the responsible application (e.g. a http link with my default browser). How can I do that? Is that possible?
> > >
> > > Regards,
> > > Albert
> >
> > A valid URL cannot include spaces (they must be replaced by %20), so if it is itself between spaces, "+yiW (with the cursor anywhere on it) will yank it to the clipboard. Similarly "+yi< or "+yi> if it is between <>, etc., see ":help object-motions". Then you can paste it into your favourite browser's URL bar.
> >
> > This question (or at least this answer) applies to vim (compiled with +clipboard, of course) on any platform, not just on the Mac, so it should have been asked on the vim_use group.
> >
> > Best regards,
> > Tony.
> > --
> > A "No" uttered from deepest conviction is better and greater than a
> > "Yes" merely uttered to please, or what is worse, to avoid trouble.
> > -- Mahatma Gandhi
>
> Thanks for the answer.
>
> But I really want to click on it with my mouse cursor. Also, it should not be pasted to the clipboard; I want it to open the responsible application right away automatically. As if you click a link in any other application.
>
> This is MacVim specific, I think.
>
> Best regards,
> Albert

If Sylvain's answer (below) is not good enough for you, then remember that Vim is keyboard-oriented: it was first released to the public 22 years ago, with a tradition that already then went back 15 years. At those times, a mouse was something rare or even unheard of in a computer room, except maybe as a tiny grey mammal that should never have been allowed to get in. So everything that Vim can do, it can do with the keyboard, and even with a keyboard lacking arrow keys and numeric keypad; if these are present, it can use them; it can also use the mouse, but not to do anything.

You can set up mappings for the mouse by using the <> names laid out under :help mouse-overview and :help double-click, but only to do things that Vim can already do by other means. For instance you could set up

:map <LeftMouse> yiW

to click anywhere and copy that Word (anything between spaces) to the "nameless" register but that wouldn't invoke the OS-defined helper application for it, and in addition it would obscure the (IMHO more useful) use of a left click to position the cursor.

Other than that, I cannot help you here. I just wonder why you are dead set on clicking to invoke any possible responsible program for whatever would happen to be under the mouse pointer: see among others the last item under :help design-not. With Vim, it often happens that best results are obtained by keeping an open mind, and accepting solutions that achieve the desired (long-term) result, or something close enough to it, by ways totally different from one had in mind at the outset.


Best regards,
Tony.
--
        THE LESSER-KNOWN PROGRAMMING LANGUAGES #10: SIMPLE

SIMPLE is an acronym for Sheer Idiot's Monopurpose Programming Language
Environment.  This language, developed at the Hanover College for
Technological Misfits, was designed to make it impossible to write code
with errors in it.  The statements are, therefore, confined to BEGIN,
END and STOP.  No matter how you arrange the statements, you can't make
a syntax error.  Programs written in SIMPLE do nothing useful.  Thus
they achieve the results of programs written in other languages without
the tedious, frustrating process of testing and debugging.

--
--
You received this message from the "vim_mac" 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

---
You received this message because you are subscribed to the Google Groups "vim_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: make URLs clickable

Steven Michalske

On Nov 2, 2013, at 5:14 PM, Tony Mechelynck <[hidden email]> wrote:

> On Saturday, November 2, 2013 3:42:14 PM UTC+1, Albert Zeyer wrote:
>> On Saturday, November 2, 2013 11:52:19 AM UTC+1, Tony Mechelynck wrote:
>>> On Friday, November 1, 2013 9:29:03 PM UTC+1, Albert Zeyer wrote:
>>>> Hi,
>>>>
>>>> I want to be able to click on URLs I see in MacVim so that it opens the URL with the responsible application (e.g. a http link with my default browser). How can I do that? Is that possible?
>>>>
>>>> Regards,
>>>> Albert
>>>
>>> A valid URL cannot include spaces (they must be replaced by %20), so if it is itself between spaces, "+yiW (with the cursor anywhere on it) will yank it to the clipboard. Similarly "+yi< or "+yi> if it is between <>, etc., see ":help object-motions". Then you can paste it into your favourite browser's URL bar.
>>>
>>> This question (or at least this answer) applies to vim (compiled with +clipboard, of course) on any platform, not just on the Mac, so it should have been asked on the vim_use group.
>>>
>>> Best regards,
>>> Tony.
>>> --
>>> A "No" uttered from deepest conviction is better and greater than a
>>> "Yes" merely uttered to please, or what is worse, to avoid trouble.
>>> -- Mahatma Gandhi
>>
>> Thanks for the answer.
>>
>> But I really want to click on it with my mouse cursor. Also, it should not be pasted to the clipboard; I want it to open the responsible application right away automatically. As if you click a link in any other application.
>>
>> This is MacVim specific, I think.
>>
>> Best regards,
>> Albert
>
> If Sylvain's answer (below) is not good enough for you, then remember that Vim is keyboard-oriented: it was first released to the public 22 years ago, with a tradition that already then went back 15 years. At those times, a mouse was something rare or even unheard of in a computer room, except maybe as a tiny grey mammal that should never have been allowed to get in. So everything that Vim can do, it can do with the keyboard, and even with a keyboard lacking arrow keys and numeric keypad; if these are present, it can use them; it can also use the mouse, but not to do anything.
>
> You can set up mappings for the mouse by using the <> names laid out under :help mouse-overview and :help double-click, but only to do things that Vim can already do by other means. For instance you could set up
>
> :map <LeftMouse> yiW
>
> to click anywhere and copy that Word (anything between spaces) to the "nameless" register but that wouldn't invoke the OS-defined helper application for it, and in addition it would obscure the (IMHO more useful) use of a left click to position the cursor.
>
> Other than that, I cannot help you here. I just wonder why you are dead set on clicking to invoke any possible responsible program for whatever would happen to be under the mouse pointer: see among others the last item under :help design-not. With Vim, it often happens that best results are obtained by keeping an open mind, and accepting solutions that achieve the desired (long-term) result, or something close enough to it, by ways totally different from one had in mind at the outset.

Also in the help under :help double-click
"Exception: In a Help window a double click jumps to help for the word that is clicked on."
This is a president for a keyword URL clicking action, although with a double click.

In response for look and feel of a Macintosh application there are certain features expected.  Agreeably in core vim this would be a non feature, but in the MacVim GUI we already have contextual menu, apple specific key bindings and other integrations into the OSX Eco system.  I feel that the addition of the OSX data detector features may be advantageous.  it seems the design-not feelings would apply to gvim, not MacVim.

For a more supported model currently; you can use a double click and extend it.

An idea could be to call the osx open utility with the contents of the selection of the word if it meets the following requirements
You can start with this....
:map <2-LeftMouse> :exe "! open ". expand("<cWORD>")<CR>

Note anything you double click will be passed to open.....  not exactly what you wanted, but you could pass it to a vim script function that verified that it was a proper url then open it.

From a google search, I found this stack overflow article.
http://stackoverflow.com/questions/7686115/vim-add-clickable-label
The second entry looks like a good model to follow.  bonus points for making the double click fall through and select the <cword>, when it is not a valid URL.


Happy hacking,  keep us moving forward!
Steve

--
--
You received this message from the "vim_mac" 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

---
You received this message because you are subscribed to the Google Groups "vim_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: make URLs clickable

Steven Michalske

On Nov 2, 2013, at 6:01 PM, Steven Michalske <[hidden email]> wrote:

>
> On Nov 2, 2013, at 5:14 PM, Tony Mechelynck <[hidden email]> wrote:
>
>> On Saturday, November 2, 2013 3:42:14 PM UTC+1, Albert Zeyer wrote:
>>> On Saturday, November 2, 2013 11:52:19 AM UTC+1, Tony Mechelynck wrote:
>>>> On Friday, November 1, 2013 9:29:03 PM UTC+1, Albert Zeyer wrote:
>>>>> Hi,
>>>>>
>>>>> I want to be able to click on URLs I see in MacVim so that it opens the URL with the responsible application (e.g. a http link with my default browser). How can I do that? Is that possible?
>>>>>
>>>>> Regards,
>>>>> Albert
>>>>
>>>> A valid URL cannot include spaces (they must be replaced by %20), so if it is itself between spaces, "+yiW (with the cursor anywhere on it) will yank it to the clipboard. Similarly "+yi< or "+yi> if it is between <>, etc., see ":help object-motions". Then you can paste it into your favourite browser's URL bar.
>>>>
>>>> This question (or at least this answer) applies to vim (compiled with +clipboard, of course) on any platform, not just on the Mac, so it should have been asked on the vim_use group.
>>>>
>>>> Best regards,
>>>> Tony.
>>>> --
>>>> A "No" uttered from deepest conviction is better and greater than a
>>>> "Yes" merely uttered to please, or what is worse, to avoid trouble.
>>>> -- Mahatma Gandhi
>>>
>>> Thanks for the answer.
>>>
>>> But I really want to click on it with my mouse cursor. Also, it should not be pasted to the clipboard; I want it to open the responsible application right away automatically. As if you click a link in any other application.
>>>
>>> This is MacVim specific, I think.
>>>
>>> Best regards,
>>> Albert
>>
>> If Sylvain's answer (below) is not good enough for you, then remember that Vim is keyboard-oriented: it was first released to the public 22 years ago, with a tradition that already then went back 15 years. At those times, a mouse was something rare or even unheard of in a computer room, except maybe as a tiny grey mammal that should never have been allowed to get in. So everything that Vim can do, it can do with the keyboard, and even with a keyboard lacking arrow keys and numeric keypad; if these are present, it can use them; it can also use the mouse, but not to do anything.
>>
>> You can set up mappings for the mouse by using the <> names laid out under :help mouse-overview and :help double-click, but only to do things that Vim can already do by other means. For instance you could set up
>>
>> :map <LeftMouse> yiW
>>
>> to click anywhere and copy that Word (anything between spaces) to the "nameless" register but that wouldn't invoke the OS-defined helper application for it, and in addition it would obscure the (IMHO more useful) use of a left click to position the cursor.
>>
>> Other than that, I cannot help you here. I just wonder why you are dead set on clicking to invoke any possible responsible program for whatever would happen to be under the mouse pointer: see among others the last item under :help design-not. With Vim, it often happens that best results are obtained by keeping an open mind, and accepting solutions that achieve the desired (long-term) result, or something close enough to it, by ways totally different from one had in mind at the outset.
>
> Also in the help under :help double-click
> "Exception: In a Help window a double click jumps to help for the word that is clicked on."
> This is a president for a keyword URL clicking action, although with a double click.
>
> In response for look and feel of a Macintosh application there are certain features expected.  Agreeably in core vim this would be a non feature, but in the MacVim GUI we already have contextual menu, apple specific key bindings and other integrations into the OSX Eco system.  I feel that the addition of the OSX data detector features may be advantageous.  it seems the design-not feelings would apply to gvim, not MacVim.
>
> For a more supported model currently; you can use a double click and extend it.
>
> An idea could be to call the osx open utility with the contents of the selection of the word if it meets the following requirements
> You can start with this....
> :map <2-LeftMouse> :exe "! open ". expand("<cWORD>")<CR>
>
> Note anything you double click will be passed to open.....  not exactly what you wanted, but you could pass it to a vim script function that verified that it was a proper url then open it.
>
> From a google search, I found this stack overflow article.
> http://stackoverflow.com/questions/7686115/vim-add-clickable-label
> The second entry looks like a good model to follow.  bonus points for making the double click fall through and select the <cword>, when it is not a valid URL.
>
>
> Happy hacking,  keep us moving forward!
> Steve


On a side note, this would be a nice to have feature for markdown and html documents.  is it already done in one of their plugins?


--
--
You received this message from the "vim_mac" 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

---
You received this message because you are subscribed to the Google Groups "vim_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: make URLs clickable

Albert Zeyer
I found the utl Vim script bundle (http://www.vim.org/scripts/script.php?script_id=293) and thought this would be a good base.

I started a simple own implementation here: https://github.com/albertz/vim-mouseclick

It kind of works, but is far away from what I would have liked, e.g.:

- When I mouseover a valid URL/filename/clickable-thing, it should change my mouse cursor to the usual click-cursor (usually a hand) and underline the word under the mouse cursor.

- I would like to get some feedback what it would do when I click on something, e.g. as a tooltip or whatever is appropriate.

--
--
You received this message from the "vim_mac" 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

---
You received this message because you are subscribed to the Google Groups "vim_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.