Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable 'gx' in Vim? Mine doesn't work anymore

I have tried wiping my .vimrc, uninstalling all plugins, updating Vim, trying different shells, etc. but I absolutely can't get 'gx' to work over a given URL. I have used it before and it worked fine, it even use to open up my finder directory if I 'gx'ed on a blank line. I tried running 'gx' over numerous URLs, above them, below them, adding "/" at the end, etc. Still no luck. I am simply at my wits end trying to figure out why it no longer works when it use to. Sometimes it will open a URL in a blank buffer with the buffer name equal to the URL and other times nothing happens. I would be grateful to anyone who actually knew what the hell is going on with this stupid thing.

I am on the latest version of OS X and have the latest version of Vim.

UPDATE

I found the answer to this question but still am not quite sure why it worked and my original approach didn't.

Original Approach

I installed iTerm2 and was forced to set Preferences >Profiles >General >Command >Command >/usr/local/bin/zsh -l. Even though I ran $ chsh -s /usr/local/bin/zsh and added /usr/local/bin/zsh to /etc/shells, I could not get >Profiles >General >Command >Login (radio button) to work.

I would either get an error message in Terminal or the window would simply flash and disappear in iTerm. However, running my profile command /usr/local/bin/zsh -l in my mind should have forced the shell to run in login mode (the same mode as my default) but it caused major issues in vim where I couldn't get any shell command or function that relied on shell commands to work (e.g :!ls, gx).

ANSWER

Moreover, I finally managed to get everything working perfectly after running chsh -s /bin/bash (e.g. back to its default). Suddenly, I was able to run both Terminal and iTerm with the radio button for Login checked and all my issues went away. It should be noted that I tried to chsh -s /usr/local/bin/zsh and received an error that I didn't receive the first time--something about a non-standard login shell.

This wasn't good enough though because I really wanted to use my Homebrew zsh (and bash) shells since they are more current. Finally, I found the answer, I ran sudo dscl . change /users/$USER UserShell /bin/bash /opt/local/bin/zsh and I was then able to leave the Login radio button checked and actually use -zsh for the first time without any issues.

NOW MORE QUESTIONS

My questions now are: 1.) Why didn't my original profile command, /usr/local/bin/zsh -l work as though it was my default Login shell? Aren't they the same (e.g. a login shell is a login shell)? 2.) If I update /etc/shells with /usr/local/bin/zsh why would I receive a "non-standard shell error"? 3.) I read the MAN page on dscl but don't understand how that actually changed my Login shell when chsh -s /new/shell/path didn't work? 4.) Does ANYBODY really know what the heck is going on here?!

If you are a moderator please let me know if I should break these questions up into different posts but this is sort of a big issue and I can't believe I am the only one who has had this problem as I couldn't find ANY Q & As that thoroughly explained what is going on. Thank you all in advance for your help!

like image 508
tommyc38 Avatar asked Dec 23 '15 05:12

tommyc38


2 Answers

I'm on OS X and running the following command in vim worked for me:

:let g:netrw_browser_viewer='open'

See also this similar answer for Fedora:

:let g:netrw_browsex_viewer="setsid xdg-open"
like image 147
jtpereyda Avatar answered Nov 16 '22 00:11

jtpereyda


I had the exact same problem, and it ended-up getting resolved (+quite a few bonuses) from this small but effective plugin:

https://github.com/stsewd/gx-extended.vim

Adds support for partial URLs, markdown URLs, 'Plugin' -> github paths, etc. It is much better behaved than netrw.

like image 36
dougpa Avatar answered Nov 16 '22 00:11

dougpa