VIM 自动完成 - 使用 $ 作为单词分隔符

发布于 2024-08-16 03:24:36 字数 596 浏览 2 评论 0原文

假设我在源文件中输入了以下内容。

var myFunction = function() { };

var anotherFunction = function() { };

var test-m

我现在可以按 Ctrl + P,它将在自动完成列表中显示“myFunction”。这很棒而且很有帮助。

但我想做的是让 VIM 像对待“-”一样对待“$”。

因此,当我键入

var myFunction = function Module$m  

并按 Ctrl+P 时,它将在自动完成中显示 myFunction。

查看了这个问题并尝试使用 iskeyword 命令将 $ 设置为关键字,但它没有没有帮助。

我知道这是可能的,因为我以前曾经让它工作过,然后我弄乱了我的 VIMRC,我无法再让它工作了。 :(

感谢您的帮助,谢谢!

Let's say I have following typed in my source file.

var myFunction = function() { };

var anotherFunction = function() { };

var test-m

I can now press Ctrl + P and it will show 'myFunction' in the autocomplete list. It's great and very helpful.

But what I want to do is make VIM treat '$' in the same way it treats '-'.

So when I type

var myFunction = function Module$m  

and press Ctrl+P and it will show myFunction in autocomplete.

I have looked at this question and tried setting $ as keyword using iskeyword command but it didn't help.

And I know it's possible to do this as I used to have it working before and then I messed up my VIMRC and I am not able to get it work anymore. :(

Your help is appreciated, thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岛徒 2024-08-23 03:24:36

要使 vim 使用美元符号作为单词分隔符,请执行以下操作:

:set iskeyword-=\$

如果想要相反的操作:(要自动完成包含美元符号的单词,请将文字美元符号添加到当前自动完成匹配模式中,方法是相反:

:set iskeyword+=\$

要查找当前的 iskeyword 设置,请执行以下操作:

:set iskeyword?

这将显示 vim 认为单个单词的 ASCII 范围列表,如下所示:

iskeyword=@,48-57,_,192-255

To make vim use a dollar-sign as a word separator, do:

:set iskeyword-=\$

If wanting the opposite: (to autocomplete words containing a dollar sign, add a literal dollar sign to the current autocomplete match pattern, by doing the opposite:

:set iskeyword+=\$

To find your current iskeyword setting, do:

:set iskeyword?

This will show you a list of ASCII ranges vim considers a single word. Mine looks like:

iskeyword=@,48-57,_,192-255
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文