I'm trying to make a vim iab statement in m开发者_开发百科y vimrc file that will take "__div" and insert with the cursor in between the open and close div tag.
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).
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.
Why does this not work?
You are in insert mode, so, of course, it does not work. You should add <C-o>
before :call
and <CR>
after (or you won't get it executed). But I suggest you write the following instead:
inoreabbrev __div <LT>div><LT>/div><C-o>F<
精彩评论