检测折叠线或增量搜索(?)
好吧,我同意——这个标题毫无用处。问题是,我不知道如何将其放入一个衬垫中...
我想做的是映射空格键,以便它充当 :nohl 映射,但是同时,当它处于折叠线上时,在正常模式(打开/关闭折叠)下充当za
。
这可能吗?
我遇到的麻烦是区分两者 - 有没有办法“检测”光标下方的折叠线,或检测“当前正在进行”的增量搜索(例如,有一些突出显示的内容)?
或者我以完全错误的方式解决这个问题?欢迎所有建议!
Okey, I agree - the title is useless. The thing is, I have no idea how to put this into a one liner...
What I'm trying to do is to map the space key so that it serves as a :nohl mapping, but at the same time, when it is on a folded line, to serve as a za
in normal mode (open/close fold).
Is this even possible?
What I'm having trouble is distinguishing between the two - is there a way to "detect" a folded line below the cursor, or to detect an incremental search "currently in progress" (as in, there is something highlighted)?
Or am I tackling this in a completely wrong way? All advices welcomed!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
重用 Andy Rk 的想法:
Reusing ideas from Andy Rk:
它可能很难看,但它对我有用:
缺点是在展开的行上按空格时会发生错误。
It may be ugly, but it worked for me:
The drawback is an error occuring when pressing space on unfolded lines.
合并对我之前评论中列出的问题的修复:
似乎没有办法检测是否有活动的搜索突出显示,因此如果您在折叠内有活动的搜索,这将清除搜索,但也会关闭折叠。在这种情况下,另一个空间应该可以让您回到您想去的地方。
Incorporating fixes to the issues I listed in my earlier comment:
There doesn't seem to be a way to detect that there's an active search highlight, so if you have a search active inside a fold, this will clear the search but also close the fold. In that case, another space should put you right back where you want to be.