显示标签为“vim”的博文。显示所有博文
显示标签为“vim”的博文。显示所有博文

2009年3月2日星期一

vimperator小技巧两则

Firefox扩展vimperator确实让我很多操作都不用通过鼠标来驱动了,而是改用接近与vim的方式。

但一直有个不太方便的地方: 为了屏幕实用空间,guioptions选项保持为空比较好,但常常要通过菜单访问一些设置等,这时通过set guioptions=mT打开了菜单和工具条,用完了又想隐藏掉,很麻烦。后来发现有如下两个小技巧可以绕开这个问题:
  • emenu命令执行菜单项对应的动作,比如:emenu 文件.打印… 不过奇怪的是这个省略号跟中文全角省略号一样,并不是三个点(英文版上也是这样,:help emenu给出的例子也是这样)
  • 在.vimperatorrc中设置guioptions=mT,Firefox启动后手工设置为空。然后在Firefox中用一个标签页打开chrome://browser/content/ 这个特殊的URL,这样可以在这个特殊的标签页中选择菜单项进行一些设置(这个方法在vimperator 2.0beta中不好使:-( )


2008年9月14日星期日

Firefox上的命令行: Ubiquity和Vimperator

前几天Firefox的新扩展Ubiquity掀起了一个热潮,都说是浏览器上人机交互的突破。

GUI的优势在于上手比较容易,而CLI的优势在于效率更高。其实Ubiquity并不是第一个这么干的,这之前的vimperator扩展也早通过模拟vi里面的ex命令的方式,实现了Firefox上的命令行,比如输入:tabopen google就能在新的标签页中打开http://www.google.com ,输入 :dialog addons就能显示"附加组件"对话框,也可以跟ubiquity一样扩充新的命令但vimperator的主要目的在于模仿vi/vim的操作方式,"模"的问题决定了很多人不会使用,或者不愿使用。

(BTW: 最开始vimperator给我看Google Reader造成了很大的不便,因为快捷键都得先按一下Ctrl-V才行,烦得要命,好在不久发现可以用autocomand在某些网址上禁用vimperator的键拦截(在vimperator中输入:help autocommand可以找到相应说明,不过那个网址匹配表达式需要懂一点JavaScript才能搞懂怎么写)

不过Ubiquity似乎比普通CLI要跟强一些,还可以利用命令的输出与网页交互。以官网的视频里 的第一个例子来说,以前我们要跟朋友相约去哪里吃饭,发电子邮件时需要这样:先到某个网址查饭馆联系方式,然后将内容拷贝粘贴到邮件中,然后又 Google Maps上找相应的地图,然后点击拷贝图片和链接到邮件中,最后发送。但现在只需要在写邮件时,用map命令查出地图,点击一些"insert into page"就可以将地图直接放入邮件了,而饭馆的信息则可以通过yelp来查然后添加到邮件中(当然,这些命令对应的网站能否服务于我这里是另外一个不得 不考虑在内的问题)——这倒有点象vi中用!!调用外部命令并将其输出插入到当前文本中来。

2005年11月29日星期二

vim-cream的tear-off menu

vim的菜单是支持tear-off的(gtk, motif 1.2或者win32版本), 但装了cream(debian package)之后,菜单就不再能够拆下来了。

vim的文档里面说可以用":tearoff 菜单名"这个命令来手工将一个菜单拆下来。

注意: 1. 对于已经翻译过的菜单,直接使用翻译过的名字,比如简体中文环境可以用":tearoff 编辑(E)";

2. vim是采用'.'来分隔多级菜单的,比如用":tearoff 设置(S).色彩主题(C)"就可以拆下cream的color scheme菜单,然后我们就可以一个个地试验那个颜色比较养眼了。

当然,如果你想主菜单创建的时候就有那个用于拆卸的分隔条,也是可以办到的: set guioptions+=t,但我看见cream/cream- settings.vim里面特意关闭了这个选项,不知道是不是有什么特殊的原因。

链接:

Tear-off menu 有什么不好
vim -cream的菜单国际化(i18n)支持

2005年2月11日星期五

Vim Tip #118: Configure gVim as Internet Explorer 'View Source' editor

http://vim.sourceforge.net/tips/tip.php?tip_id=118

The reason:
- Hated it when the file was "Too big for notepad" :)
- syntax highlighting

Key point:
1. How to make gvim the IE's 'View source' editor
2. How to let it auto syntax higlighting, as the temporary file might has no extension.

Answers:
1.
REGEDIT4 [HKEY_LOCAL_MACHINESOFTWAREMicrosoftInternet ExplorerView
Source EditorEditor Name]
@="c:Program Filesvimgvim.vbs"
Here's
another problem: "Unfortunately, you can't specify a quoted filename
argument here, i.e. "%1". The editor specified is supposed to handle
filenames which contain spaces(which come from 'Temporary Internet
Files') ."(seems that IE6 doesn't have this limitation). Thus we
need a vbs wrapper (or a shortcut with arguments specified) to quote
the argument.

2. gvim -c syntax=html

Powered by ScribeFire.

2005年1月8日星期六

vim-cream的菜单国际化支持

前几天给vim-cream的菜单做了一下国际化(i18n)支持,仿照vim自己的菜单i18n方法写的。
当然同时还做了简体中文的翻译(可到我的主页下载cream-menu-lang.zip)

前日才有机会发给cream的群组,今日收到cream的开发者回信说接受了,并且0.33版本将考虑更多的国际化支持(而不仅仅是菜单)。

以下是菜单国际化的支持补丁,但需要针对自己的语言编写菜单翻译脚本放到cream/lang目录下(参见我的中文翻译范例)

(Here is the patch for i18n of the menu. But you need to write the menu translation script for your own language. Check my translations for Simplified Chinese as an example)

--- cream-menu.vim.orig 2004-02-02 22:23:18.000000000 +0800
+++ cream-menu.vim 2004-12-02 11:52:18.000000000 +0800
@@ -21,6 +21,57 @@
" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
" 02111-1307, USA.
"
+function! Load_menu_translation()
+ " copied from vim's own menu.vim, with a little modification
+if exists("v:lang") || &langmenu != ""
+ " Try to find a menu translation file for the current language.
+ if &langmenu != ""
+ if &langmenu =~ "none"
+ let s:lang = ""
+ else
+ let s:lang = &langmenu
+ endif
+ else
+ let s:lang = v:lang
+ endif
+ " A language name must be at least two characters, don't accept "C"
+ if strlen(s:lang) > 1
+ " When the language does not include the charset add 'encoding'
+ if s:lang =~ '^aa|^aa_aa'
+ let s:lang = s:lang . '.' . &enc
+ endif
+
+ " We always use a lowercase name.
+ " Change "iso-8859" to "iso_8859" and "iso8859" to "iso_8859", some
+ " systems appear to use this.
+ " Change spaces to underscores.
+ let s:lang = substitute(tolower(s:lang), '.iso-', ".iso_", "")
+ let s:lang = substitute(s:lang, '.iso8859', ".iso_8859", "")
+ let s:lang = substitute(s:lang, " ", "_", "g")
+
" Remove "@euro", otherwise "LC_ALL=de_DE@euro gvim" will show English menus
+ let s:lang = substitute(s:lang, "@euro", "", "")
+ " Change "iso_8859-1" and "iso_8859-15" to "latin1", we always use the
+ " same menu file for them.
+ let s:lang = substitute(s:lang, 'iso_8859-15=', "latin1", "")
+ menutrans clear
+ exe "runtime! cream/lang/menu_" . s:lang . ".vim"
+
+ if !exists("did_menu_trans")
+ " There is no exact match, try matching with a wildcard added
+ " (e.g. find menu_de_de.iso_8859-1.vim if s:lang == de_DE).
+ let s:lang = substitute(s:lang, '.[^.]*', "", "")
+ exe "runtime! cream/lang/menu_" . s:lang . "*.vim"
+
+ if !exists("did_menu_trans") && strlen(LANG) > 1
+ " On windows locale names are complicated, try using LANG, it might
+ " have been set by set_init_1().
+ exe "runtime! cream/lang/menu_" . tolower(LANG) . "*.vim"
+ endif
+ endif
+ endif
+endif
+endfunction
+

function! Cream_menus()
" Creates each menu loader and calls it
@@ -60,5 +111,7 @@ function! Cream_menus()
let &cpo = cpo_save

endfunction
+source VIMRUNTIME/delmenu.vim
+call Load_menu_translation()
call Cream_menus()



Powered by ScribeFire.