Working with Vim, Part 3: Vim Scripting

Presented at Still Hacking Anyway (SHA2017), Aug. 7, 2017, 9 a.m. (60 minutes)

If you're a Vim user, Vimscript is one of the most useful programming languages you could know! This workshop is meant for Vim users who want to take the next step in boosting their efficiency. We'll start with some explanations on the basics of the language: commands, functions, variables. We'll talk about how files get loaded and when. Piece by piece, we'll build a simple plugin of our own. Vimscript has a bit of a scary reputation. People don't seem to like it a whole lot. Not to mention that it's not used anywhere else, so you don't end up learning it in university, or as a junior in your job. Well, I'd like to convince you that it's not scary at all, and it's very, very useful. It's actually quite a simple language with straightforward language constructs. If you have knowledge of any imperative language, you'll find Vimscript very easy to learn. And once you do understand the basics, building your own Vim extensions will be right around the corner. I've built dozens of published Vim plugins (just check my <a href="https://github.com/AndrewRadev?utf8=✓&tab=repositories&q=&type=source&language=vim%20script">github repositories</a>), and I have a lot more scripts in my vimfiles. With my guidance, we'll start writing some Vimscript to solve simple problems, and piece by piece, we'll build a plugin of our own. We'll make it flexible, we'll provide configuration options, we'll even throw in some documentation that integrates with the built-in :help system. But don't worry -- you don't need to build a full-blown plugin to create something useful. Once you understand the Vim runtime path and how files get loaded, you'll find it's as easy to write a small Vim script, as it is to write one in bash.

Presenters:

  • Andrew Radev
    Web developer (Rails, Ember.js), sworn Vimmer. Professionally, I code mostly in Ruby, Rails, and a bit of Ember.js. In my spare time (and very non-professionally), I try to play around with all sorts of other stuff: Image processing, gamedev with Unity, opengl and webgl, Android, electronics, and any fun programming-related thing that crosses my path. I'm a dedicated Vim user and I've created a bunch of Vim plugins. I maintain the VimLinks twitter account, I'm one of the maintainers of the official ruby bindings for vim (but I'm pretty bad at keeping up with the work there), and I own the runtime files for Vim's eco support.

Links:

Similar Presentations: