Writing My First Vim Extension

Sunday, December 07, 2014

Although I have been using Vim on a daily basis for several years now, I have avoided Viml (this Vim scripting language) like the plague. The idea of having to learn a new programming language just to make some customizations to a text editor did not seem appealing to me at first. With that being said, upon thinking about it more I realized that learning to customize Vim on deeper level is really a time investment in a tool that I will continue using for many years to come.

Even though there are Vim extensions written for nearly every situation, I could not find one that wraps and unwraps function arguments to my satisfaction. There is a module with similar functionality available on GitHub titled argumentrewrap, but I found it lacking as it does not allow the unwrapping of arguments and periodically spews errors during normal use (but I appreciate the effort). Before going further, I should probably explain what exactly I want to be able to do.

Basically, I want to take a definition that looks like this:

Foo(wibble, wobble, wubble)

And automatically turn it into this:


After spending the better part of a week reading online tutorials and Vim documentation, I wrote what I feel is a "correct" implementation titled argwrap.vim. Although there were various caveats in the Vim scripting language that I ended up getting snagged by (such as strings auto-converting to zero), I was pleasantly surprised that Viml wasn't as terrible of a programming language as I had imagined it to be. It actually has a lot in common with languages such as Python and JavaScript (particularly with respect to arrays and dictionaries).

The following sites are good reference materials for those who want to dive into Vim scripting themselves:

Updating Projects

Friday, October 24, 2014

I'm currently in the process of updating the projects section of this site to include some of the older applications that I developed in the past but am no longer maintaining. Even though they were written quite a long time ago, they are interesting from a historical point of view and are sometimes useful as reference. The newly added projects are:

Enoshima Fireworks

 Sunday, October 19, 2014

Firework shows in Japan tend to be very crowded; if you want to have any chance to sit down at all, you have to arrive several hours in advance. Last night we went to one in Enoshima, a local tourist spot within cycling distance of Shonandai. This was fortunate, as trying to get on the same train as everyone else to go back home can be a challenge. I took some pictures of the fireworks during the show, which lasted about 45 minutes. As most of these shows happen during the summer, it is likely that this is was the last chance to see fireworks this year.

Thoughts on the TOEIC

Saturday, October 18, 2014

Seeing as the TOEIC (Test of English for International Communication) is all the rage here in Japan amongst professionals and seeing that my girlfriend is studying to improve her score on it, I decided to see what kind of challenge it would present to a semi-native speaker of the English language.

Although I have never taken it, the TOEIC is considered to be easier than its cousin the TOEFL (Test of English is a Foreign Language). Unlike the TOEFL, which is said to focus on skills needed in everyday conversation, the TOEIC is supposed to be all about "Business English" (read: Dilbert English). This is somewhat counter-intuitive as I would expect the English used in a corporate environment to be more difficult to master for foreign speakers than the casual expressions and vocabulary we use everyday.

The test consists of 200 questions total, divided evenly into listening and reading sections, and takes two hours to complete. The difficulty of questions varies a lot, but for the most part it did not pose a significant challenge and I was able to complete it with about half an hour to spare. My final score was 100/100 on listening and 97/100 on the reading sections; this translates to an overall score of 980 out of a possible 990.

While two of the mistakes I made were due to lack of concentration, one reason for the last error remains hard to grasp:

The plans are motivated by increased demand for Dixon products in several
markets. In addition to the Slough facility, Dixon has a smaller production
plant in Cardiff, Wales, where a similar project commenced early last year.
The work at Cardiff ______ within seven months.

A. has been completed
B. will be completed
C. was completed
D. will have been completed

The correct answer is C, but the reason for why the other options (especially A and B) are incorrect remains unclear to me. This goes to show that textbook grammar is not something that even native speakers can treat lightly.

Site Redesign and Future Plans

Thursday, October 09, 2014

After using the Pelican static site generator for managing this site for close to a year, I decided to give Hexo a try, recognizing it as an opportunity to experiment more with JavaScript and Node.js (both technologies that I'm increasingly using for prototyping as of late). As much as I liked being able to make modifications to Pelican's inner workings and themes in Python (the best programming language of all time), over time I grew somewhat tired of the inconsistencies and overall clunky feel of it.

Now that I finally have a publishing platform that I'm fully satisfied with, I will transition from continuing to contribute content to Facebook, a service that doesn't have its users' privacy and interests in mind). The frequency of posts will probably vary a lot, but I'm likely to stick with it.