Home >Documents >Daniel Fischer's Blog - A Starting Guide to VIM From Textmate

Daniel Fischer's Blog - A Starting Guide to VIM From Textmate

Date post:27-Nov-2014
View:146 times
Download:0 times
Share this document with a friend

A Starting Guide to VIM from TextmateRead Later

November 19th, 2010

Daniel, Whats Your Deal?

For about four years Ive been using Textmate almost every day. Im very fast with it. Ive always thought about switching over to VIM or Emacs but I have been scared of losing my speed. In fact, Ive actually tried Emacs in the past and also wrote a blog post on my experience. I liked it in general, but I ended up coming back to Textmate after a week. Why? I didnt really feel like I was gaining anything. So, why would I even consider switching over to VIM? Server-Side SSH Editor Split Windows CTags Large Development Community & Support Mastering VIM will lead to greater overall efficiency, given the limited potential of Textmate. What do I mean by the last item? If you master VIM and its special commands, you can be shockingly more efficient than what Textmate allows. The main reason being VIMs movement commands and VIM-only plugins. I feel like Im as fast as Im going to get in Textmate, but I want to be faster. I also really want to leverage some powerful plugins that the VIM community has created for development, and I also really want to leverage the power of split windows. One use case for split windows that absolutely strikes my fancy is being able to see a frontend .haml file and also see the appropriate .scss file at the same time. Ooh, just the thought gives me a bout of excitement.So, bye for now Textmate. Youve been great, but I dont see you providing me with many more advanced features. Ive out grown you. I crave more complexity and efficiency. Of course youve told me that you have an improved version of yourself coming out in some vaporware universe of time, but I just dont know how to trust that. So for now my good friend, I am going to hang out with VIM.** I know you could argue using Emacs for the same points. However, I tried it, and I didnt like it. Something draws me more to Vim and thats what Im committing to.

Whats My Workflow Like?

My general workflow: Front-End Development Heavy. Back-End Development as needed. Beware, because below this sentence is a journey through my mind, and that can be a scary one indeed. You will see me talking to myself as if you were I, and I were you. Of course, this

is to only answer questions within my own head, that may in fact also be in your head.

Shall We Proceed?

First off, which VIM installation do I go with?

Theres a few different installations that I came across, but it seems that MacVim is the standard right now. So off I go to install MacVim. I grabbed the latest snapshot of MacVim from GitHub. The reason I did this instead of downloading the one from the Google Code page is because the Google Code page installation is two years old, and the MacVim team has been under heavy development for the past two years, so you can imagine how much you are missing out on. Download the latest snapshot here. Follow the instructions in the wiki/Building on how to install it. Be sure to copy mvim in the src/MacVim/mvim to /usr/bin so you can type mvim like you typed mate in Terminal.app First, lets tackle something valuable and simple. Learning how to use VIM like a pro. The first thing I did was fire up my terminal and type vimtutor. Notice that I didnt fire up MacVim to do the tutor. Biggest reason? I knew MacVim would look like crap without tweaking and I also didnt want to utilize the OS X adjusted shortcuts that MacVim provides. I prefer to go style natural in the beginning. You can skip this step if you want, but if you truly are coming from Textmate to VIM, I highly recommend you to take 30 minutes and just go through the quick tutorial. Itll give you a glimpse into the power of VIM and help remedy the steep learning curve that VIM requires.Okay great. I have a general understanding of how to move around in VIM and I see its potential. Now its time to fire up MacVim and make it sexy and then figure out what common plugins there are that the Ruby community uses.

I Installed MacVim, Now What?

Why does the sexy part even matter? Im a visual person. The editor that I use must be visually appealing to me, and visually reflect sexy code. This is how I interact with my material, and if it doesnt look pleasing then I am turned off and cannot be productive. This is one of the reasons why I picked Textmate from the beginning, the themes made the code look really attractive. I feel like I can get an attractive and geeky feel out of MacVim so lets see how it ends up. Launch macvim by either opening it in your installation folder, or navigate towards a project and type mvim . like you would type mate . My biggest visual problems initially: Black & White Theme Scrollbars Toolbar Application Icon So first thing I do is create my own icon. Yes, Im insane, I know. Lets just accept it, and move on.

acVim Icon Fischy Style

acVim Icon Fischy Style Dark Lets Get Dirty with Themes & PluginsWhere do I begin to customize my theme? What are the standard plugins that the Ruby community uses? My solution? Ask people that know better than me: my network on Twitter.

Within a couple minutes I had direction: Use the Github Janus script for common plugins and themes. Follow the instructions in the README.markdown which will also be outputted on the Github Janus Project Page. After you follow the instructions you should have a full installation of common plugins & themes that the majority Ruby VIM community uses.Great, I have all of these awesome plugins and themes. How do I use it? First, I need to change my damn theme!

Depending on where you are, and what youve done. You may need to relaunch MacVim in order to pull in these new plugins. Lets see some colors. Type :color and then tab to see a list of installed colors. molokai is my favorite one that I stuck with and tweaked slightly. If you want to see your current theme simply type :color. Heres a site that shows you a preview of each installed theme that came with Janus. Once I was happy with my color settings I also realized I needed some transparency. In order to do that go to your preferences cmd + , click advanced and then click Use experimental renderer. Once you do that, open or create /your_home/.vimrc.local and add the following: set transparency=15 Youll have to relaunch MacVim to use the experimental renderer. Once you do that you can tweak the transparency at any time by typing :set transparency=[value here]Awesome. I am starting to love the visual aspect of VIM and my code. One more problem these damn scrollbars are annoying me. How do I get rid of that?

Append the following to /your_home/.vimrc.local: set guioptions=aAce

Relaunch MacVim and boom, everything should look pretty damn sexy now.This is awesome. VIM looks awesome, my code syntax highlighting looks awesome. But what the heck is that sidebar? How do I use it? What plugins did Janus install that will help with my development? How does MacVim help me over a standard terminal vim?

Well, theres a lot to cover, and Im not going to cover everything. What I recommend doing is simply reading the README.markdown of Januss project page and going over each plugin that is installed. What I will tell you though, is that the benefit of using MacVim is you have familiar key bindings natively installed to VIM like most OS X applications. cmd + s, etc. One thing you may not notice initially, especially if youve used VIM exclusively in a terminal environment, is that youre able to interact with MacVim using your mouse. If you initially open MacVim and click in that project drawer looking thing, youll notice you can double click and open files. This is cool. You can also drag the columns to resize the split windows.

Split Windows

That brings me to another thing. Split windows. You have two awesome commands at your utility. :split: and :vsplit I tend to use :vsplit more than :split For example, in terminal.app open up a typical rails project cd ~/Projects/some_rails_project then type mvim . the same way you would have to open up a project with mate . You should have MacVim open with two windows. Both are using NERDTree for that project drawer looking thing. Thats fine, use the right buffer and open up a file.Cool! It opened up a file and I see sexy syntax.

Now type :vsplitWow! Thats pretty cool. I can look at multiple files at once. I like this!

Yes, yes, I know. It is a very powerful feature. Probably my favorite feature. Now to see something cool, use your mouse to select one of the buffers and then type cmd + t (yes, youll recognize that from Textmate) and open up another file.Yes! I can see two files at once. This is awesome. And there is familiarity with Textmate. I like where this is going.

I like where this is going as well. The funny and sad part is this is only the tip of the iceberg. If I were to go through everything that Ive learned within a day, then I dont know. Id be more crazy than what I already sound like talking to myself in a blog post.

Window Shortcuts

After splitting several windows, there were times I wanted to grow the window without dragging the column bar. After some research I figured out the way to do this was to type ctrl + w + (optional number for amount) + > or This will increase the current buffers width by a single pixel. If I wanted to expand it by 50 pixels I would type ctrl + w + 50 + > Theres also another cool command, type ctrl + w + = to equalize all buffer widths. I think of ctrl + w as control window.Im starting to get a hang of these split windows. One question though, how do I close one of the split windows?

Hey, after all, this is about going from Textmate to VIM right? So, just type cmd + w. Yep, it feels just like home.

Cool Daniel, Share a Screenshot With Us!

This screenshot from left to right (NERDTree, b

Embed Size (px)