One week ago I started to have a deeper look into Haxe. One of the first things I realized was, that on OS X a bugfree, enterprise-like IDE is missing, so I thought to have a look at VIM.

VIM is a text-editor, that has a steep learning curve. The first days were frustrating, because a lot of simple tasks just doesn’t work out in the usual way.

I still just know some basic stuff, but I really learned to love VIM. Some things can be done much, much faster than in texteditors of IDE’s like Eclipse.

Here are my tips, that should help other people who want to give VIM a try:

  1. I first tried VIM, later on I switched to MacVim. MacVim has a few advantages over the OSX Terminal-Vim:
    • Tabs are a great way to keep multiple instance of vim editors open. When you use VIM-Windows for a lot of files you easily loose focus. Tabs are easier to handle.
    • The Fullscreen mode of MacVim is really nice.
    • It has bindings to the standard OS X Keyboard shortcuts.
    • Mouse support works very well (for example resizing VIM-Windows)
    • I suggest you to use the default VIM at first to learn the basics: how to navigate, edit, copy/paste, search/replace etc, then later switch to MacVim to use advantages of both worlds.
  2. At first I installed plugins the common way. I copied plugin files and/or syntax files in special folders. It was okay, but I discovered a better, more easier way to do it later on: Vim-Addon-Manager.
    • The installation is very easy.
    • You can install plugins for VIM with a simple command or entry in the .vimrc file. It automatically downloads the required files, copies them to the right place and even puts default settings in your vimrc file. Just lean back and enjoy.
  3. This one is not VIM specific, but it helped me to work much faster: I minimized the keyboard repeat delay rate with the following shell command:
    defaults write NSGlobalDomain KeyRepeat -int 0
  4. When you start to work with VIM you often need to adjust the settings, so I added the following entry to my .vimrc:
    map <F12> :edit ~/.vimrc<CR>

    and the following line to .gvimrc:

    map <F12> :tabedit ~/.vimrc<CR>

    Now, when I press F12 the config file opens up directly (in MacVim in a new tab).

  5. In Eclipse I often use ALT-CursorUp/Down to move lines, well, you guessed it, up and down. With the following settings it’s also possible with VIM (Shift-K / Shift-J):
    " Bubble single lines
    nmap <S-K> ddkP
    nmap <S-J> ddp
    " Bubble multiple lines
    vmap <S-K> xkP`[V`]
    vmap <S-J> xp`[V`]
  6. I also have done a lot of other mappings. I mapped various plugins and tasks like FuzzyFinder, NERDTree, moving through VIM-Windows, etc. to special keys. This is really great in VIMyou can configure everything the way you like it.
  7. I tried some plugins. Here are the ones that I like most:
    • FuzzyFinder – Surf through your filesystem with wildcards.
    • NERDTree – the explorer/finder for VIM. In MacVim there is an ugly scrollbar when you open NERDTree. The following line disables it:

      :set guioptions-=L
    • Taglist – Shows variables, classes, functions. Similar to an outline browser. With the following command you can create a tagfile of your complete project, which is very helpful sometimes:

      :TlistAddFiles **/*.hx
    • snipMate – Incredible helpful tool: You can create code templates. This improves productivity a lot. A must have!
    • tComment – Comment in/out lines in your source.
  8. It’s possible to compile directly from within VIM using the make command. I have added a make.sh file into my Haxe project folder that looks like that:
    #!/bin/bash
    cd ~/Documents/Haxe/Demo/
    haxe project.hxml

    Then I added the following lines to my .vimrc

    let g:haxe_build_hxml="/Users/jochenheizmann/Documents/Haxe/Demo/project.hxml"
    set makeprg=~/Documents/Haxe/Demo/make.sh
    
    map <F5> :w!<CR>:make<CR>:copen<CR><C-w>6-<CR>

    If I press F5 in VIM it starts to compile the project, then if any compiler errors found it opens a small quicklist window where I can browse through the source files and errors. Great!

Omnicron doesn’t work yet

The only thing I still have problems with is the omnicron code-completion. I have tried various things, but if I open the autocompletion in VIM for an object, it shows up a lot of methods and members that don’t belong to the selected object. I think it is easier to setup it for other languages (I will try that soon), but for Haxe it didn’t worked out so fine. If you have any tips for me how to make it work, please let me know.

However, I really like VIM. If you learned the most important shortcuts and commands, you can work very fast.

I will use it for at least one month, then I decide if I continue to code my projects in it or not. It’s already my default texteditor.

Finally…

Here are some nice resources that helped me to get started (thanks to my twitter followers for recommend them to me):

My VIM-Configuration

You can find my vim configuration at github.

  1. Dad (2010-11-27 09:37)

    Maybe you’d like BBEdit. It shouldn’t be very difficult to make a language module for syntax coloring for Haxe and you can have shell windows (very nice), project windows and text windows for a near IDE feel.TextWrangler is the free only slightly limited version of BBEdit if you want to try out a free version.

  2. joe (2010-11-27 21:39)

    I used textwrangler as my default text editor before i switched to Vim/MacVim. It’s a very good editor.

Add your comment now