简体   繁体   English

在vimrc iab语句中调用search()无效

[英]call to search() in vimrc iab statement not working

I'm trying to make a vim iab statement in my vimrc file that will take "__div" and insert with the cursor in between the open and close div tag. 我试图在我的vimrc文件中制作一条vim iab语句,该语句将使用“ __div”并将光标插入在打开和关闭div标签之间。

From reading online, I should be able to do the following to make it work: 通过在线阅读,我应该能够执行以下操作:

iab __div <div>!cursor!</div>:call search('!cursor!', 'b')cf!

I've tried it in gvim 7.3 on Windows and vim 7.2 in Linux, and it hasn't worked (all I get is the full string, with the search call in text, inserted into my file). 我已经在Windows的gvim 7.3和Linux的vim 7.2中进行了尝试,但是它没有用(我得到的只是完整的字符串,带有文本的搜索调用,已插入到我的文件中)。

From reading online, it sounds like there may have been some changes to the search() function as of vim 7. But I can't find any specifics that would explain why this doesn't work. 从在线阅读开始,听起来好像在vim 7上对search()函数进行了一些更改。但是我找不到任何可以解释为什么它不起作用的细节。

Why does this not work? 为什么这不起作用?

You are in insert mode, so, of course, it does not work. 您处于插入模式,因此,它当然不起作用。 You should add <Co> before :call and <CR> after (or you won't get it executed). 您应该在:call之前添加<Co> ,并在之后添加<Co> <CR> (否则您将无法执行它)。 But I suggest you write the following instead: 但我建议您改写以下内容:

inoreabbrev __div <LT>div><LT>/div><C-o>F<

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM