如何使用< c-y>扩展UltiSnips代码段在YouCompleteMe弹出菜单中? [英] How to expand an UltiSnips snippet using <c-y> in the YouCompleteMe pop-up menu?

查看:138
本文介绍了如何使用< c-y>扩展UltiSnips代码段在YouCompleteMe弹出菜单中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题真的让我感到不安.我同时拥有 YouCompleteMe 这个问题.不过,我的问题更具体.当我编写类似<html的代码时,会出现一个弹出菜单,向我显示该代码的所有相关代码段.

This problem really hit a nerve with me. I have both YouCompleteMe and UltiSnips installed on my vim 8.0 editor. It seems that both of these plugins use the tab key for doing the auto-completion and that has created an incompatibility that has been also addressed by this question. My question is more specific, though. When I write a piece of code like <html, there is a pop-up menu that shows me all related snippets for that code.

我使用 tab 键浏览该菜单,但是当我按下 ctrl + y 接受并因此扩展其中一个代码片段时,什么也没发生!我认为这种结构表明,可以通过某种方式从菜单中选择其中一个片段,而无需尝试为UltiSnip定义快捷方式.我究竟做错了什么?我应该如何导航并选择这些片段?

I use the tab key to navigate through that menu but when I hit ctrl+y to accept and therefore expand one of these snippets, nothing happens! I think this structure suggests that it's possible to somehow choose one of those snippets from the menu without trying to define a shortcut for UltiSnip. What am I doing wrong? How should I navigate and choose those snippets?

我也不想用任何新插件(例如supertab等)来填充我的vim.

I also would not want to stuff my vim with any new plugins (like supertab, etc.).

推荐答案

该解决方案实际上比我预期的简单得多.一开始,我因为不知道而感到愚蠢,但是当我发现类似的问题时,例如

The solution was actually a lot simpler than I expected. In the beginning, I felt stupid for not knowing it but when I find a similar question like this one, I thought that probably many were fallen into the same trap.

我不知道是否将其命名为bug,但这是Ultisnips和YouCompleteMe一起工作的方式.为了扩展代码段,您必须完全按照定义的方式编写初始化程序.当然,这似乎很明显,但是当您看到包含不同代码段的弹出菜单时,您可能会认为它们可以是可以选择的,但只有在您已经完全按照定义编写了代码段初始化程序后,它才能起作用.

I don't know whether to name it a bug or not but it's how Ultisnips and YouCompleteMe work together. In order to expand a snippet, you have to write the initializer exactly as it's defined. Of course, this seems obvious, but when you see a pop-up menu of different snippets, you might think they can be chosen but it only works if you already wrote the snippet initializer exactly as it's defined.

因此,当片段称为"html5"时(如我的问题所示),写一个额外的左括号(<)会使它停止工作.无法扩展.

So when a snippet is called "html5"---as it's shown in my question---writing an extra opening bracket (<) will cause it to stop working. It cannot be expanded.


另外,不要忘记查看
Siegfried Gevatter 配置.不能同时使用 tab 键导航到弹出菜单和展开代码片段.


Also, don't forget to check out Siegfried Gevatter configuration. It's not possible to use tab key both for navigating into the pop-up menu and expanding the snippets.

P.S..如果在弹出菜单中导航可以更改整个单词(包括尖括号),而不是仅更改后继单词,则很好.此功能在我看到的大多数其他编辑器中都以这种方式工作,这也许就是为什么我一开始无法发现问题的原因.

P.S. It was nice if navigating through the pop-up menu could change the whole word (including the angle bracket), not just what succeeds it. This feature works this way in most of the other editors I see and that's probably why I wasn't able to spot the problem in the beginning.

这篇关于如何使用&lt; c-y&gt;扩展UltiSnips代码段在YouCompleteMe弹出菜单中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆