开发者

How to change part of the string in current buffer path

开发者 https://www.devze.com 2023-02-15 13:01 出处:网络
I\'m using the following line in _vimrc to launch current buffer in firefox in windows abbrev ff :! start firefox开发者_JS百科 %:p<cr>

I'm using the following line in _vimrc to launch current buffer in firefox in windows

abbrev ff :! start firefox开发者_JS百科 %:p<cr>

There are two problems:

1) When I do :ff and there are spaces in path, then the buffers are launched in separate tabs.

2) Also, I want to replace C:/wamp/www in %p to http://localhost/ when opening in firefox, so that I don't have to change it manually, when working with local server.

How to achieve this?

UPDATE: solution:

I've Removed shellescape() and it works perfectly in windows. I use the following code in vimrc now.

abbrev ff :exec '! start firefox 'substitute(expand('%:p'), '^C:/wamp/www/','http://localhost/','')<CR>

Thanks El Isra for the code.


Try with this:

abbrev ff :exec '! start firefox '.shellescape(substitute(expand('%:p'), '^C:/wamp/www/','http://localhost/',''))<CR>

0

精彩评论

暂无评论...
验证码 换一张
取 消