No more ~/.nvimrc - Neovim folder now at ~/.config/nvim

Just in case you missed the announcement, Neovim now supports XDG configuration and has moved to a new configuration folder.

That means that your old ~/.nvimrc and ~/.nvim paths won’t work anymore by default. It’s possible this came as a shock to you when you updated and realized none of your configuration or plugins work anymore.

The fix is very easy though.

mv ~/.nvim ~/.config/nvim
mv ~/.nvimrc ~/.config/nvim/init.vim

Or alternatively, create some softlinks.

How to use shell variables in awk

If you ever find yourself in a life-or-death kind of thing where you’re forced to use shell variable in your awk scripts, then fear not!

First, here’s what doesn’t work (warning: contrived example):

statement=$(echo "something is not cool" | sed -e 's/cool/awesome/')
# $statement is now "something is not awesome"
first=$(echo "$statement" | awk '{ print $1 }')
# $first is now "something"
# now let's pipe $statement into awk to print the first, second and
# fourth column, but only if the first column matches $first!
truth=$(echo $statement | awk '$1 ~ $first { print $1, $2, $4 }')
echo $truth
# nothing happens

The problem is that awk doesn’t know about $first_word.

The solution (or one of the possible solutions) is to teach it in the BEGIN block. Here’s the right code:

Read More

Three things I learned from rewriting hexo-easy-edit

Earlier today I ended up rewriting the Hexo plugin I wrote a couple of days ago. The reason was that I suddenly realized a better approach. And what’s more: after rewriting it, it was almost child’s play to add a couple of extra features and general niceties.

Besides being able to edit any blog post of a Hexo blog in your editor of choice from the command line using a regular expression on the title and/or subfolder, you can now also filter on tags and plugins and open newly created posts automatically. Also, the little menu now displays your posts in chronological order :-)

Now, I’m by no means an expert of course, but I’d like to jot down a couple of thoughts, because I feel like I did learn some valuable lessons from writing this modest but actually useful plugin.

Read More

Hexo tag plugin snippets for everyone

As I noted in my last post about Hexo, I’m not a big fan anymore of fancy CMS-style administration panels for blogging. Nowadays, I do pretty much all my writing in vim using markdown.

This is actually a pretty big deal for me because I used to be a professional writer/translator, so I’ve spent a lot of time in various administration panels and WYSIWYG editors. If only I’d known back then what I know now: that the combination of vim and markdown blows them all out of the water..

Either way, snippets is what I wanted to talk about here. Since I started blogging again, I’ve been making new UltiSnips snippets whenever I came across new opportunities to use them.

hexo-tag-plugin-snippets screenshot

I’m blogging with Hexo so most of my snippets are centered around Hexo’s tag plugins. But earlier, I decided to clean them up, make sure I got all of them and ported them to Snipmate (the other popular format for vim snippets) as well.

Read More

I wrote a Hexo plugin: hexo-easy-edit

I’m still pretty new to programming so forgive me if I sound overly enthusiastic, but I’m pretty psyched about this plugin I made for Hexo.

hexo-easy-edit screenshot

Hexo is a Node.js-powered static site generator and I used it to generate this very blog you’re reading right now. I’ve been trying to be more active on GitHub, but it’s pretty tough when you’re new and not feeling very confident about your abilities. So last week I rewrote most of the Hexo documentation (the maintainers are Chinese and their docs were understandably not in perfect English) in order to at least do some good work in open source.

But as I was proofreading the docs and writing a few blog posts on here, it suddenly occurred to me that a) I could really use a tool to help me blog more efficiently, and b) I actually knew enough JavaScript-fu to do it. So I wrote it, pushed it to GitHub and npm, then pushed it a few more times because I kept finding little bugs and updating the readme (lesson learned: test more before pushing), and here it is!

Read More