Use Vim to write iOS programs

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.