Rubénerd :)

Sunday 21st March 2010

Graduating from nvi, kinda

nvi saying hello

After using it as my primary editor for several weeks, I feel as though I can finally graduate from nvi. It was more challenging than I thought it would be when I first decided to learn it, but it was a fantastic learning experience.

Read this post >

Sunday 14th March 2010

Trying out the nvi editor

nvi

Having fun with FreeBSD on my Libretto this afternoon, I didn’t have internet access to install Vim from ports so I decided to finally learn more about the bundled nvi editor. I missed syntax highlighting, but if you customise it right it’s still a nice, lightweight, capable editor.

Read this post >

Tuesday 07th April 2009

Restoring files with MacVim, Vim

MacVim informting me of a file that can be restored

It seems deliriously (some of you might say schadenfreude) ridiculous that I would take so much time to create a follow-up post to my initial MacVim review and include some commentary regarding my forgetful nature… then forget to add something. Can banging your head on a table cause brain damage?

One more reason to consider MacVim if you’re looking for an all purpose text editor for Mac is a feature it shares with regular Vim: the ability to restore text files that were lost as a result of the program quitting unexpectedly. If you relaunch MacVim you’re asked if you want to restore the text file to the condition it was last in regardless of when you saved it.

As with most Mac applications MacVim has never crashed on me before, but that’s not to say I haven’t been the victim of an old battery that decides to turn the computer off!

That reminds me, I need to buy a new battery. This one is shot worse than a politically incorrect reference to Dick Cheney. Wow, that was over three years ago already?

Monday 06th April 2009

Followup to my MacVim review last year

Vim (left) compared to MacVim (right)
Vim (left) compared to MacVim (right)

I try my best to include as much information from personal experience as I can when I do my reviews of software here, but sometimes I forget something critical which later involves me hitting my head on a table or similarly raised flat surface.

In August of last year I wrote up a review of the MacVim text editor which, as you’ve probably already figured out, is a native Cocoa port of the venerable Vim text editor. Back then I admitted I didn’t see the point of using MacVim when Vim was already available in Mac OS X and could easily be accessed from the Terminal [Wikipedia], but I stated I’d started using MacVim anyway.

I thought I’d clear up some ambiguity now that several months have passed: MacVim is the ultimate Mac text editor and I use it exclusively now for everything! It has become such a critical part of my life now that I can’t possibly imagine going back to TextMate or TextEdit [Wikipedia]. It’s an excellent application that works just as regular Vim does, but with all the benefits of being a native Cocoa application such as native file open and save windows, a broader range of colours for syntax highlighting… plus gosh darn it, it just looks nice!

Since my initial review I’ve also learned more regarding execution from the Terminal. I’ve broken the post up into three sections, to pretend I’m organised.

1. The mvim script

Terminal.app iconPaulo posted a question on my original review and answered it before I even could! If you’re reading this Paulo, do you have a website you want me to link to?

Thanks for sharing this! One question thou: I’ve used ports install MacVim and I can’t find the mvim script that is supposed to be shipped with it. Am I missing something?

[...]

Figured that you need to get the version from the project’s web site at http://code.google.com/p/macvim/

2. Using an ampersand to stay in the shell

Terminal.app iconThis is something I already knew given I use FreeBSD so heavily now, but I realised others might not. If you want to execute MacVim in a directory from the Terminal but you still want to work in that directory, you can append an ampersand to the command:

% mvim [filename] &

This is really useful if you want to edit source code in MacVim and compile it in the Terminal.

3. Command aliases for the absent minded

Terminal.app iconAnother tip from Unix is adding aliases to your profile shell script so if you’re like me and you absent mindedly type vim or vi when you meant mvim you’ll execute the right thing! First check which shell you’re running:

% echo $SHELL

Then append these lines to your appropriate file. Leopard uses bash by default but given I’m a FreeBSD guy I still prefer tcsh.

For bash, ~/.profile, ~/.bash_profile or ~/.bashrc:
alias vim="mvim"
alias vi="mvim"

For tcsh, ~/.tcshrc or ~/.cshrc:
alias vim "mvim"
alias vi "mvim"

Wednesday 27th August 2008

A revisited MacVim editor review

About a week ago I posted (amongst other ramblings) that I had successfully moved over to the Vim text editor for most of my day to day… editing. I mentioned how I loved the syntax highlighting and how much it improved the readability of code, and how I had got used to the two mode operation and most of what I would consider to be the basic and intermediate commands.

MacVim icon
MacVim in the /Applications folder

Unfortunately I also said that I had installed Vim from MacPorts on my MacBook Pro to use in the Terminal and that I failed to see what the point would be of installing the dedicated graphical MacVim application. I’ve since been proven wrong and have even started using MacVim as my primary editor for everything I do on this machine, and I love it!

ASIDE: Despite what you may think, I was not paid any money to create this post. Isn’t it a sad state of affairs these days when you have to go on record saying that you’re not being paid off? Sheez Lousie!

My incorrect assessment stemmed from my own misunderstanding of what MacVim was capable of; I assumed that it was just an Aqua version of GVim, or in English a Mac OS X native version of graphical Vim that didn’t need X11. While this is true, it does have features that put it far ahead of the simple Terminal based Vim I was advocating before.

Firstly, the syntax highlighting which what made me fall in love with Vim from the beginning is far richer in MacVim because it supports full 16bit colour, not 16 colours. Below is a comparison of a simple Ruby script I wrote shown in MacVim and Vim:

Vim (left) compared to MacVim (right)
Vim (left) compared to MacVim (right)

Now obviously I could go into my Terminal.app preferences to get the same background colour and font size, but the colours definitely look nicer in MacVim. I’m one of those fruitjobs who sees their code as poetry, and as with all art it looks far nicer when presented in a nice frame :-).

Another feature of MacVim given that it’s a native Mac OS X Aqua application is that along with the regular [esc]+[:]+command Vim commands, it also supports native Mac shortcuts. This means to open a file I can enter :o ~/Documents/MyFile.rb or just as easily enter [Command]+[O] and use a regular Mac OS X dialog box.

Then there are the little things that perhaps don’t improve usability in the traditional sense, but make the program nicer to use such as native, Safrai like tabs, the utilisation of the Mac menu bar and a native Mac toolbar you can collapse. It also throws errors using native Mac windows:

Mac-like error message
Mac-like error message

My final concern with using a graphical MacVim application instead of the command line Vim was that I spend most of my life in the Terminal and would hate to have to move to the Dock, click the application icon and navigate to the file I want when I might already be there in the Terminal. Fortunately in the MacVim archive you download there’s also a small mvim script you can put in any folder in your shell’s $path which will automagically launch the MacVim application whenever you enter mvim filename from the Terminal, just as with TextMate. I chose to put my mvim file in /usr/local/bin given I’m also a FreeBSD guy.

Having used MacVim for just over a week now, I can confidently say it has really made my life much easier. If you’re on the hunt for a text editor for Mac OS X and don’t like the idea of shelling out an arm and a leg for shareware that isn’t even as good anyway, give it a try! I love it so much I’m going to make a donation this afternoon: after all I would think paying for something you don’t need to pay for is much higher praise than being told you have to pay or it will cease to work, right?

MacVim is available from it’s Google Code project page.

Tuesday 19th August 2008

It turned into a Vim and GNU nano ramble post

Because I still don’t have my audio equipment and therefore can’t record Rubenerd Shows, as usual I have to offload my scattered thoughts and ramblings here instead. For a more authentic Rubenerd Show experience, try reading the post out loud to thin air with a somewhat Aussie accent that people in Singapore and Malaysia think sounds more British, and sprinkle in a few "that doesn’t make any sense", "what bothers me about the whole thing" and "I like grilled cheese sandwiches" remarks.

View outside the Boatdeck Cafe
View outside the Boatdeck Cafe, from my Flickr profile

I’m sitting at the Boatdeck Cafe in Mawson Lakes once again on my laptop. Despite getting broadband at the house only last week, I’m the kind of person who can’t live his whole life at either work, uni or home. Check that, I’m the kind of person who can’t do work just at work, uni or home. For some reason I’m always more productive at coffee shops. I can’t imagine what I might be ingesting there that would cause me to act differently.

To continue this post by not actually mentioning anything of substance, I’m typing this post using Vim in the Terminal on my MacBook Pro. After a brief flirtation with TextMate last year and an even briefer encounter with Apple’s bundled TextEdit.app, I’m back to the command line. To tell the truth for the longest time I was a GNU nano person; it was the first text editor I ever learned to use on a Unix-like system back when I had my first job during high school, and I loved how straightforward and simple the commands were. I even wrote a few wrapper scripts around it to make it more flexible back when I was obsessed with Perl. I still really like nano.

                :::                         The
  iLE88Dj.  :jD88888Dj:
.LGitE888D.f8GjjjL8888E;       .d8888b.  888b    888 888     888
iE   :8888Et.     .G8888.     d88P  Y88b 8888b   888 888     888
;i    E888,        ,8888,     888    888 88888b  888 888     888
      D888,        :8888:     888        888Y88b 888 888     888
      D888,        :8888:     888  88888 888 Y88b888 888     888
      D888,        :8888:     888    888 888  Y88888 888     888
      D888,        :8888:     Y88b  d88P 888   Y8888 Y88b. .d88P
      888W,        :8888:      "Y8888P88 888    Y888  "Y88888P"
      W88W,        :8888:
      W88W:        :8888:     88888b.   8888b.  88888b.   .d88b.
      DGGD:        :8888:     888 "88b     "88b 888 "88b d88""88b
                   :8888:     888  888 .d888888 888  888 888  888
                   :W888:     888  888 888  888 888  888 Y88..88P
                   :8888:     888  888 "Y888888 888  888  "Y88P"
                    E888i
                    tW88D                 Text Editor

Fancy ASCII art from the Nano homepage.

Anyway back to Vim: I have been used to using vi and vim for a while now, but only recently have I started using Vim almost exclusively. I absolutely love how I can throw source code written in virtually any programming language or script and it will detect it and give it the correct syntax highlights. I’m a very visual person, and reading code in Vim is an absolute pleasure. I’ve also got used to modal data entry and know most of the basic commands. What astonishes me though is in learning Vim you uncover even more functions you didn’t know existed. In a way, you don’t know how little you know until you’ve learned how to use some of it, if that makes any sense, which I’m sure it didn’t.

Reading back to an earlier edition of the Linux Format magazine from the UK, I came across a project called Cream which essentially takes Vim and adds a whole tone of extra features and changes some of the more ambiguous commands. I’m hesitant to try it out until I’m off my training wheels using Vim as it is: I’m worried if I got used to using a fuzzy extra layer on top of Vim instead of Vim itself I’ll never learn how to use it properly. It does look really interesting though, if you’ve had experience with it I’d love to hear about it.

Peter Krantz's ultimate VIM Keyboard!
Peter Krantz’s ultimate VIM Keyboard!

Well how about that, this post which started off as useless rambling is actually going somewhere. Wonders never cease. Except in black holes; I heard the gravity in black holes is so strong not even light or wonders can escape, let alone ceasing wonders.

The last thing to mention with regards to Vim is whether it’s worth running a graphical version. On Mac OS X I have several options: the MacVim project provides a native Aqua graphical port complete with Safari-like tabbing and Mac-like anti-aliased text. Alternatively I can just fire up MacPorts and install Vimwith gtk enabled , then launch it from the Terminal with the -g option.

MacVim on Mac OS X Leopard
MacVim on Mac OS X Leopard.

Having chosen the former and used it for a few hours, I appreciate being able to launch Vim from a slick icon on the Dock and having it associate with text and source code files in the Finer, but aside form those I don’t see any real difference. It has a toolbar, but I fail to see what the point is considering Vim is a keyboard driven application! And while the tabs are nice to use, I find it much easier just using a tabbed shell emulator with a seperate Vim session running in each, and tweaking my .vimrc to enable syntax highlighting and a few other options. For what it’s worth, I know the commandline Vim supports multipe documents per session too, and I’m sure as I get more used to it I’ll be trying it out, but for now this is a nice compromise.

I’m also aware that as a Vim user I’m supposed to make a comment about how the Emacs editor is unnecessarily bloated, suffers from acute feature creep, takes far too long to load, is unreliable, has a crappy logo, doesn’t work as well over a bandwidth-constricted SSH session, flies in the face of the Unix philosopy of only doing one thing and doing it well, uses ridiculous key combinations, induces premature carpel tunnel syndrome, accelerates arthritis in the fingers and looks cheaper when run as a graphical GTK application… but I’m going to take the high road in this case and refrain from comment ;-).


One of the longest running posts on my Anime blog is what editors the peoples from Suzumiya Haruhi no Yūutsu would use. Haruhi probably uses Emacs because she’s such a control freak, Mikuru probably uses Vi because she’s a time traveller and needs travel light, and Yuki simply sends hexadecimal code from her brain. We have interesting conversations at 2am when we’re half asleep.

In other news, Ruben was bashed up this afternoon by a band of Emacs programmers who said that his editor of choice didn’t even have an email client, tetris game or coffee machine built into it. Ruben attempted to retort by claiming that he was in fact glad that his editor of choice couldn’t be used to send email, play tetris or brew coffee, but he was out cold before he got the chance. For what it’s worth, they spared his life because he mentioned that Windows was ikky, that he thought Japanese and Korean culture is cool and that he didn’t have a girlfriend. Had he been wearing a Vista lanyard, he would have been in dire straits.

Here I am again in this mean old town
And youre so far away from me
And where are you when the sun goes down
Youre so far away from me …

… Custom kitchen delivery
We’ve gotta move these refrigerators
We’ve gotta move these colour tee-veeeeees…

UPDATE: I admit I’ve started using MacVim after all. It just looks too nice to pass up, and it fits in so well with the rest of the desktop.

Monday 19th May 2008

VIM security note for FreeBSD folks

Installing vim on FreeBSDIf you install the vim text editor either from packages or ports, just a reminder from the FreeBSD Security Team:

SECURITY NOTE: The VIM software has had several remote vulnerabilities discovered within VIM's modeline support. It allowed remote attackers to execute arbitrary code as the user running VIM. All known problems have been fixed, but the FreeBSD Security Team advises that VIM users use 'set nomodeline' in ~/.vimrc to avoid the possibility of trojaned text files.

If you install lots of ports at once or just happened to have vim installed automatically because it was listed as a dependency, you may not have see that message. Take care.

Dedicated to my groovy late mum Debra Schade.