Using Vim instead of (or with) Xcode for iOS Development

Xcode comes with a lot of the things you need to create an iPhone and / or iPad. In fact, I don’t even know many of them, because it’s so “behind the scenes”.

On the other hand, I was recently introduced to the benefits of using Vim as an editor. Are there any settings that could make using Vim an effective option when developing for iOS platforms? Or would it be so difficult to combine these two issues so that this issue is controversial?

In other words, if you have any tips, tricks, or warnings when using Vim and Xcode together, I'm all ears!

+61
vim ios xcode
Jul 17 2018-12-17T00: 00Z
source share
8 answers

Developing for iOS or Mac with Vim can be very powerful and fast, especially if you are using TDD or want feedback.

But his work requires a bit of finalization. A few important things you need to know:

  • Use the xcodebuild command line xcodebuild to run your build and units from some vimscript.
  • Use the clang_complete plugin to give you complete code completion from vim.
  • Use the ios.vim and cocoa.vim plugins to navigate.

This is my preferred method of work. In fact, I wrote the ios.vim plugin to make it easier for more people.

+86
Jul 18 2018-12-18T00:
source share

I'm already there ...

I love vim and regularly use it in my daily development in C ++ on * nix platforms, but I also like all the functions of Xcode, which, especially with the latest versions of Xcode> = 4.3 and clang, provide a real plus for autocomplete terms and links to characters.

I think I found the best solution with a great (although not officially supported by Apple) XVim plugin .

Hoping that future updates to Xcode will not break it (it still works fine with previews of the latest versions 4.5), it really allows you to move your fingers like you did in Vim while working with Xcode, which, as I said, is optimal for me decision.

+19
Jul 17 '12 at 12:27
source share

Vim and Xcode will coexist together, provided that you are not trying to edit the same files at the same time in Vim and the Xcode editor. If you do this, each of them will give you a warning that the file has been modified externally. The terminal version of Vim is a little easier to live in this particular respect: it will only warn you when you try to save the file, asking if you are sure, while MacVim and the Xcode editor will warn you every time you return to the file .

Xcode allows you to select an external application when opening files by file type. In the Xcode settings, go to the File Types tab, and then file-> text-> source code. The preferred editor can be configured to an external program such as MacVim; note that Emacs should already be specified as a choice: when Emacs is selected, Xcode launches Terminal.app with Emacs in the terminal. This parameter of the preferred editor has a problem that you get a new window with every open file, which may not match your workflow.

The Vim remote function may be useful here, see :help remote . With a little work and the above preference of the preferred editor, you need to be able to send the file for editing to any instance of Vim, including the existing Vim running in xterm . I seem to remember that Emacs provides something similar.

But none of this allows you to use the Vim parameter without . Preferred editor: just open and edit project files in Vim, as usual.

In your workflow, you can use Vim to edit the code and switch to Xcode to create the project, but Vim can also run the same build tools as Xcode, and with a little more work, you can even jump to lines with errors. Xcode relies on gdb for debugging, which can also be used with Vim through a plugin.

Of course, one can’t expect Vim to replace something like Interface Builder, but almost any other aspect of the iOS developer can be achieved with the Vim-only solution.

Or just use Vim for faster code editing and continue to use Xcode for the rest.

+6
Jul 17 '12 at 18:24
source share

Even MacVim's thought with YouCompleteMe is my main OSX development environment, there are tasks that I prefer to do in Xcode, such as debugging and profiling. For these scenarios, I use XVim , which adds VIM editing capabilities to Xcode.

In Xcode 5.1, XVim crashed badly. But it has progressed, and now it works fine with Xcode 6. But you only get a subset of VIM this way, for example. you cannot split the editor to view two files at the same time. You can easily enable / disable it with Shift-Command-X.

(Sorry to post this as an answer, not a comment, but the stackoverflow reputation system did not allow me)

+2
Oct. 20 '14 at 13:39
source share

There are certain advantages to using external editors (however, emacs is ten million times better than vim:}).

Stick to Xcode for most things, but when you need the power of emacs or maybe vim (the main macros of a repeating editor is my main reason), just edit the file using show in finder and open it or just switch to your editor it moves to the file from there . Xcode will understand when you go back that the file has changed.

For simple code, I stick with Xcode, this code completion is based on a more complete knowledge of the code, so that emacs or vim kicks out. Continuous code verification is invaluable, and as already mentioned, direct access to the documentation is amazing (click the button if you haven't found it yet).

+1
Jul 17 2018-12-17T00:
source share

I can not recommend YouCompleteMe enough! Besides its completion of the code, it also shows syntax errors on the fly on the affected line without the need to manually launch your compiler (ie. Very similar to the functions of the Xcode editor). The description of the creator of YCM is quite informative:

YouCompleteMe is a fast, like you, type of fuzzy code search engine for Vim. It has several completion mechanisms: an identifier engine that works with every programming language, a semantic, Clang-based engine that provides inheritance of semantic code for C / C ++ / Objective-C / Objective-C ++ (now called "C- family languages ​​") ...

To run it:

  • Follow the "Quick Install Mac OS X" section.
  • Remember to add the .ycm_extra_conf.py file to the root of your project folder



Edit:

Without a plugin such as YouCompleteMe, VIM can only do the rudimentary completion of a word (Ctrl-N), which does not know about the programming language that you use, nor about all other files belonging to your project. You also do not get a list of members of the object after entering ".". or '->'. This way you will miss a lot of help (and therefore speed), Xcode gives you when typing. Also, VIM does not warn you like Xcode when you make typos or other errors in the code. YouCompleteMe adds exactly those missing features in VIM and makes the development of iOS in VIM a joy.

You can use xcodebuild to create and run your project, but personally, I prefer to work with VIM and Xcode at the same time. Both reload documents automatically after they have been changed by others. Store Xcode for debugging, profiling, and deployment.

+1
Oct. 20 '14 at 1:31 on
source share

I like XVim for Xcode . Unfortunately, it is interrupted for Xcode 5.1 (for some people the development branch worked, but I couldn’t).

I finished the transition to AppCode after the trial version, I really liked the tab management, refactoring and code analysis. The code automatically syncs with Xcode, so I run both (Xcode for build settings, managing the asset directory. AppCode for everything else).

The first day I downloaded it, I installed IdeaVim , so I could still use some Vim keyboard shortcuts.

Although you cannot get the full functionality of Vi / Vim using the plugin. I believe that using mixed use with native IDE commands is enough to compensate.

0
Apr 23 '14 at 13:37
source share

In my opinion, Xcode is the best solution. It has so many functions that you cannot find / add to Vim. Some of them:

  • Interface Builder (to create good lookin interfaces in less time)
  • ARC (automatic reference counter management)
  • Automated process of managing code signing and presentation of the application store

The list is very long, and Apple always encourages you to use Xcode, not other IDEs.

-2
Jul 17 2018-12-12T00:
source share



All Articles