主要是符合中国人习惯的设定,%USERPROFILE%\.vimperatorrc如下:
" vim: set ft=vim: set defsearch=bing set nextpattern=下一,后一,\bnext,(>|›|>>|››|»)$,更多,\bmore\b set previouspattern=上一,前一,\b(prev|previous)\b,^(<|‹|<<|‹‹|«) set editor="gvim.exe -f" nnoremap <silent> <F8> :bmarks<CR> nnoremap <silent> <C-L> :emenu 文件.打开位置…<CR> :javascript << EOF useNeusoftProxy = function() { liberator.execute('normal :set! network.proxy.autoconfig_url=http://proxy.neusoft.com:8080/<CR>'); liberator.execute('normal :set! network.proxy.type=2<CR>'); } useIJumpProxy = function() { liberator.execute('normal :set! network.proxy.http=localhost<CR>'); liberator.execute('normal :set! network.proxy.http_port=8118<CR>'); liberator.execute('normal :set! network.proxy.type=1<CR>'); } clearProxy = function() { liberator.execute('normal :set! network.proxy.type=0<CR>'); } EOF nnoremap <silent> <F9> :js useNeusoftProxy()<CR> nnoremap <silent> <F10> :js useIJumpProxy()<CR> nnoremap <silent> <F12> :js clearProxy()<CR>
使用utf-8保存,事实上目前gvim73的win32版本还不能正常显示里面的某些符号(有几个符号编码转换失败),就用notepad编辑吧。当然如果你不是要改这几个符号的话,还是推荐使用vim哈。
其中设置编辑器是gvim.exe,前提是你把gvim的按照目录添加到了%path%里(推荐一个改path的非常好用的小工具——RedmondPath),像例子中这种情况(gvim在path里),完全不用设置editor,因为这是默认的,写出来只是方便修改。-f参数是--nofork,我也不知道具体啥意思,只是看帮助文档也这么写的。
F8映射到书签列表了。按下F8后,然后按分号,再字母o,再按相应的数字即可。
Ctrl系列火狐本身的快捷键都被vimperator屏蔽了,这里重新映射Ctrl+L打开“打开网页地址“对话框,毕竟vimperator的:open自动提示不够动态啊。
然后把F9映射到公司的代理上,F10映射到我自己做的一个代理上,F12关闭代理。
其实本来觉得挺简单的,定义几个vim脚本格式的函数就行,没想到vimperator不支持,但是它支持调用javascript函数,而且提供了对象liberator对象在javascript中使用vimperator的功能。
有个链接解释了那个type的含义:http://kb.mozillazine.org/Network.proxy.type
后来想弄到Portable的火狐上,使用这个批处理来启动火狐即可。
REM set VIMPERATOR_INIT=":source %~d0%~p0.vimperatorrc" REM Upper won't work, see this http://code.google.com/p/vimperator-labs/issues/detail?id=117 REM So I use the solution below, but it seems not to be elegant. set HOME=%~d0%~p0 start "start firefox with myfrofile" "%~d0%~p0Mozilla Firefox\firefox.exe" -profile "%~d0%~p0myprofile"
批处理会有控制台窗口一闪而过,然后就来了个jscript版的。
var script_path = WScript.ScriptFullName; script_path = script_path.substring(0, script_path.lastIndexOf('\\')); var shell = WScript.CreateObject("WScript.Shell"); // set VIMPERATOR_INIT=":source %~d0%~p0.vimperatorrc" // Upper won't work, see this http://code.google.com/p/vimperator-labs/issues/detail?id=117 // So I use the solution below, but it seems not to be elegant. shell.Environment("process").Item("HOME") = script_path; shell.run("\"" + script_path + "\\Mozilla Firefox\\firefox.exe\" -profile \"" + script_path + "\\myprofile\" -no-remote");