本文参考了vim官方网站的文档http://www.vim.org/tips/index.php。为了查找方便起见,文中的技巧编号沿用原文档中的编号。
88. 如果你使用vim的win32版,那么在_vimrc文件中加入下面这一行可以使得窗口在打开时自动最大化:
au GUIEnter * simalt ~x
关于此命令的帮助请参见:
:he win16-maximized
89. 使用:X或:set key=命令可以为文件加上密码,保存文件时该文件将被加密。再次打开该文件时vim将询问密码。使用:X并输入空密码或者:set key=命令可以解除加密。
116. 使用 [I 命令可以在所有打开的文件中搜索光标所在位置的单词,并将其以列表的方式显示在屏幕下方。
118. 使用vim作为IE的源代码查看程序。由于IE给源代码查看程序传递参数时并不会为带空格的文件名增加引号,所以需要自己写一段脚本。
'--- gVim.vbs -----------------------------------------------------------------
'function: Start gvim, combining multiple arguments to single file argument.
'changes: 20010905: Quoted 'oWShell.Run' filename argument, allowing spaces.
' 20010518: Created.
'author: Freddy Vulto <fvu@fvu.myweb.nl>
' Making variable declaration mandatory
option explicit
dim oWShell, sArg, sFile
' Create script object
set oWShell = CreateObject("wscript.shell")
' Loop through arguments
for each sArg in wscript.arguments
' Add argument to filename
sFile = sFile & sArg & " "
next
' Remove excess space
sFile = Trim(sFile)
' Run Vim with file argument. Additional arguments:
' -R: View file readonly
' -c "set syntax=html": Use HTML syntax-highlighting
' NOTE: Use "-c ""set ft=html""" to make it work for Vim v6.
oWShell.Run _
"""C:\Vim\Vim62\gvim.exe """ & _
"-R """ & sFile & """ " & _
"-c ""set syntax=html"""
' Destroy script object
set oWShell = NOTHING
然后在注册表中添加下面的值:
HKLM\Software\Microsoft\Internet Explorer\View Source Editor\Editor Name
(Default)=C:\Vim\gvim.vbs