0
我在vimrc中有一個函數。該功能是關於完成html中的標籤。如何調用vimrc中的函數取決於文件類型
42 function! InsertHtmlTag()
43 let pat = '\c<\w\+\s*\(\s\+\w\+\s*=\s*[''#$;,()."a-z0-9]\+\)*\s*>'
44 normal! a>
45 let save_cursor = getpos('.')
46 let result = matchstr(getline(save_cursor[1]), pat)
47 if (search(pat, 'b', save_cursor[1]))
48 normal! lyiwf>
49 normal! a</
50 normal! p
51 normal! a>
52 endif
53 :call cursor(save_cursor[1], save_cursor[2], save_cursor[3])
54 endfunction
55 inoremap > <ESC>:call InsertHtmlTag()<CR>
但是最近我發現了一些麻煩。當我編寫C++代碼時,在我編寫#include <iostream>
之後,vim用</iostream>
完成它。...... 只有當文件類型是.html時,纔會調用此函數。