On Wednesday, May 25, 2011 20:54:44 JP Lew wrote: > Hi there: > I use Vim to write PHP, and am looking for a way to quickly > preview PHP files through localhost. After some brief > research (http:// vim.wikia.com/wiki/VimTip1015), I came up > with the following key remap solution for Mac using xampp:
> map <F1> :w<CR>:!open -a Google\ Chrome `echo > http://localhost/${PWD\#*/*/*/*/*/}/%`<CR> > This trick works, but only if I'm editing a file which is > located somewhere in my $PWD. In other words, if % in the > register is relative (index.php or mywebsite/index.php), then > it appends smoothly onto the truncated directory structure. > However, if my present file is outside the $PWD and % is > absolute (/Applications/XAMPP/xamppfiles/htdocs/ > mywebsite/index.php), then this trick fails, and I get a 404 > error. > I can probably live with this flaw and work around it, but I > figured some of you ninjas out there might have a superior, > more comprehensive solution. > Also, is there someone out there willing to break down this > piece of code for me: ${PWD\#*/*/*/*/*/}. It manages to strip > directories from the left of the string, but how? So far I > looked here but it didn't shed any light: > http://www.gnu.org/software/bash/manual/bashref.html#Word-Spl > itting it appears to be parameter expansion -- see that same html, search on ${parameter#word}, but because the '#' is escaped it looks like an error to me, and gives a 'bad substitution' error if i try to echo that thing on the command line of course i am using a bash command line, and you mention Mac and xampp, which makes me wonder if looking at bash manuals is the appropriate place to look for all i know mac has their own flavor of shell that's disturbingly different from linux bash which is all a long winded way of saying i dunno, sorry sc -- 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
