How to work with vim and paths containing a "+" sign

时间:2015-05-18 17:27:47

标签: matlab vim

I have a MATLAB project with some folder names starting with a + (packages). When I try to open those with vim from the commandline, e.g.

vim +mytools/extrema.m

I get an error

E492: Not an editor command mytools/extrema.m

This also happens when I try to load those files from within vim using :e. When use :Explore I can navigate into the folder and open files there without any problems.

Is there a way to configure vim to be able to handle these paths?

Note: In this case I cannot rename the folder as MATLAB packages have to start with a + sign.

1 个答案:

答案 0 :(得分:4)

您可以按如下方式转义+号:

vim -- +mytools/extrema.m
:e \+mytools/extrema.m

--表示选项的结束;否则+被解释为定位光标的选项。第二种方法应在输入字符:e \+后完成选项卡。 (请注意,:e +<TAB>没有制表符,因为:edit可以选择[++opt][+cmd]作为参数。)

有关详细信息,请参阅man vim:help edit

更新:尝试

:arga +mytools/extrema.m
:argu 1

此方法绝对允许您在输入字符:arga +后从打开的Vim会话中完成制表符。

:arga[dd]将其参数添加到参数列表中,:argu[ment]编辑参数列表中的[count]参数。参数列表可以显示:ar[gs],括号中的当前参数。

此方法有效的原因是:argadd 接受[++opt] [+cmd]等标准语法,而不是:edit

有关详细信息,请参阅:help arglist