windows Vim 作为默认编辑器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5402615/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Vim as the default editor
提问by Prakhar
I'm on Windows XP and I just installed GVim 7.3. How do I make the default editor? How can I make it run using the command prompt e.g.
我在 Windows XP 上,我刚刚安装了 GVim 7.3。如何制作默认编辑器?如何使用命令提示符运行它,例如
c:\Windows>gvim boot.ini
open this file in gvim.
在 gvim 中打开这个文件。
Thanks a lot
非常感谢
回答by eckes
Add Gvim to your PATH variable
将 Gvim 添加到您的 PATH 变量
To be able to call Gvim from the command line, you have to add the installation directory of Vim to your PATH
variable. To do that, right click on My Computeron the desktop (or in Explorer) → Properties → AdvancedTab → Click on Button Environment Variables.
为了能够从命令行调用 Gvim,您必须将 Vim 的安装目录添加到您的PATH
变量中。为此,请右键单击桌面(或资源管理器)上的My Computer→ Properties → AdvancedTab → 单击 Button Environment Variables。
In the Dialog, go to the User Variablesfield and search if there is already a PATH
variable. If there is a PATH
Variable, select it, click Editand change it as follows:
在对话框中,转到用户变量字段并搜索是否已经存在PATH
变量。如果有PATH
Variable,选中它,点击Edit,修改如下:
%PATH%;C:/Program Files/Vim/Vim73
(or whatever the installation directory of Gvim is).
(或任何 Gvim 的安装目录)。
If there is no PATH
variable set, create a new one with the content written above.
如果没有PATH
设置变量,用上面写的内容创建一个新的。
Confirm everything with OK, then open a newcommand window (important!), navigate to the desired directory and type
用OK确认一切,然后打开一个新的命令窗口(很重要!),导航到所需的目录并键入
gvim somefile.txt
This should bring up your favourite editor.
这应该会调出您最喜欢的编辑器。
Set Gvim as default editor for a certain file type
将 Gvim 设置为特定文件类型的默认编辑器
Adding Gvim to your PATH
doesn't make Gvim the default editor for a certain file type. This can be achieved the following way:
将 Gvim 添加到您的文件PATH
中并不会使 Gvim 成为特定文件类型的默认编辑器。这可以通过以下方式实现:
- In Explorer, right click on any file and select Open With → Choose Program
- in the upcoming window, select Vi improved - A Text Editoror browse for gvim.exeif the entry is not already there
- select the Always use the selected program ...checkbox and click OK
- from now on, every time you double-click the file, it will be opened with Gvim
- 在资源管理器中,右键单击任何文件并选择打开方式→选择程序
- 在即将出现的窗口中,选择Vi 改进 - 文本编辑器或浏览gvim.exe如果条目不存在
- 选择始终使用所选程序...复选框,然后单击确定
- 以后每次双击文件都会用Gvim打开
The easiest way
最简单的方法
If you install Gvim, be sure to check the Add to context menuoption. If you did that, you can right click on anyfile in the Windows Explorer and select Edit with Vim.
如果您安装 Gvim,请务必检查添加到上下文菜单选项。如果这样做,您可以右键单击Windows 资源管理器中的任何文件,然后选择使用 Vim 编辑。
回答by J Bourne
Right click the any file you want to open -> select Open or Open With ->check always open with the following editor.
右键单击要打开的任何文件 -> 选择打开或打开方式 -> 选中始终使用以下编辑器打开。
回答by maverik
After installing vim the "Edit with vim..." menu item appears in the context menu (RMB click on any file to check). Thus you can edit any file (not only text file) with just selecting this menu item
Add gvim to the PATH variable and you can run it right as you want:
c:\Windows>gvim boot.ini
安装 vim 后,“使用 vim 编辑...”菜单项出现在上下文菜单中(RMB 单击任何文件进行检查)。因此,您只需选择此菜单项即可编辑任何文件(不仅是文本文件)
将 gvim 添加到 PATH 变量,您可以根据需要运行它:
c:\Windows>gvim boot.ini