I have introduced some Vim plug-ins before. There are two plug-ins that are convenient for iOS writing.Program, That is, cocoa and objc_matchbracket (hereinafter referred to as objc_mb ). The cocoa plug-in is mainly used to complete the API name of the cocoa framework, and the objc_mb is used to automatically complete the brackets.
However, these two plug-ins do not support objective-C ++ files with the suffix. Mm. You need to make some changes.
Run in VIM
1: E $ vimruntime/filetype. Vim
We found that the file types collected by VIM are quite comprehensive. Even the. MM file is known as objcpp ......
So let the plug-in support the objcpp type.
1) cocoa Plugin:
Open ~ /. Vim/plugin/cocoa. Vim, which has the following sections:
1 AU filetype objc Ru after/syntax/ Objc_enhanced.vim 2 \ | Let B: match_words = ' @ \ (Implementation \ | interface \): @ end ' 3 \ | SETl Inc = ^ \ s * # \ s * import omnifunc = Objc # cocoacomplete # complete 4 \ | If Globpath (expand ( ' <Afile>: P: H ' ), ' *. Xcodeproj ' )! = '' |5 \ SETl makeprg = open \-A \ xcode \ & \ osasloud \-e \ ' Tell \ app \ "xcode \" \ To \ build ' 6 \ | Endif
Of course I can't understand it, but copy this section and change the objc of Line 1 to objcpp so that the cocoa plug-in can support objective-C ++.
2) objc_mb plug-in:
Open ~ /. Vim/ftplugin/objc_matchbracket.vim
You cannot understand how to turn it off. Copy the file, change the file name to objcpp_matchbracket.vim, and replace objc with objcpp.
In this way, you can use the second plug-in the. MM file.
But there is still a problem-a bunch of C and C ++ plug-ins did not recognize the. MM file. I wrote a patch in the. vimrc file. You can manually modify the type of the. MM file-objcpp or CPP:
1 function changefiletypebetweencppandobjcpp () 2 If & filetype = " CPP " 3 set filetype = objcpp 4 else 5 set filetype = CPP 6 endif 7 endfunction 8 9 Map
: Call changefiletypebetweencppandobjcpp ()
in this way, you can press F4 to switch the. MM file type to adapt it to different plug-ins.