How I

Takuya Fujiwara, a.k.a. tyru

System engineer

Tokyo, Japan

Who are you and what do you use Vim for?

I’m Takuya Fujiwara, a system engineer in Japan. I’ve been working on mainly web systems in Java. I met Vim about 8 years ago.

At first, I’m afraid to say that I don’t use Vim at work so often, at least, not for development. I’m dispatched to all kinds of places as a contract employee. A such working place with various limits doesn’t allow me to use a tool which I favored freely. So I mainly use Vim only at home for hobby programming. Also at work, I use it in *nix environment because it is bundled. But I use Windows as a development machine at work.

Previously, this circumstance makes me think “Why can’t I use Vim at work too?” at first. Because I use Vim every day at home, but not at work. But now, it makes me think “Why have I been using Vim?” at all times. “What is the pros/cons of Vim?” “Is Vim really a powerful text editor comparing other text editors?” “What is the Vim way of doing that?”

And if other editors / IDEs have a great feature that Vim does not have, I can migrate it to Vim (with Vim script). And if that is impossible, I will write a Vim’s patch, But I’m not good at C as Vim script. If I cannot implement it by myself, I will often consult Vim-jp. It is Japanese Vim community mentioned later. And I send emails to vim_dev if I think it is necessary. This is “How I Vim” for my own way.

Introduce us to your Vim config.

I’ve thought for a long time that Vim script code in .vimrc should be packaged as Vim plugins as much as possible. Because:

An “executable configuration” is certainly one of the merits when we implement an application in a pluggable programming language. But it quickly makes my .vimrc unreadable. I want to write a just configuration in .vimrc, not code.

However, my .vimrc is here. It has 1600 lines, I want to package each config as a Vim plugin more!


And be careful when you read keymappings section in my .vimrc. I’m using emap.vim’s keymapping commands instead of built-in :map command.

In :map command

nnoremap <expr> j v:count == 0 ? 'gj' : 'j'
xnoremap <expr> j v:count == 0 ? 'gj' : 'j'
onoremap <expr> j v:count == 0 ? 'gj' : 'j'

In emap.vim

Map -expr [nxo] j v:count == 0 ? 'gj' : 'j'

And you can provide a leader key. (Of course, you can use <SID> or <Plug> keymapping :) )

DefMacroMap [i] compl <C-l>

Map [i] <compl><C-n> <C-x><C-n>
Map [i] <compl><C-p> <C-x><C-p>
Map [i] <compl><C-]> <C-x><C-]>
Map [i] <compl><C-d> <C-x><C-d>
Map [i] <compl><C-f> <C-x><C-f>
Map [i] <compl><C-i> <C-x><C-i>
Map [i] <compl><C-k> <C-x><C-k>
Map [i] <compl><C-l> <C-x><C-l>
Map [i] <compl><C-s> <C-x><C-s>
Map [i] <compl><C-t> <C-x><C-t>

In built-in

inoremap <C-l><C-n> <C-x><C-n>
inoremap <C-l><C-p> <C-x><C-p>
inoremap <C-l><C-]> <C-x><C-]>
inoremap <C-l><C-d> <C-x><C-d>
inoremap <C-l><C-f> <C-x><C-f>
inoremap <C-l><C-i> <C-x><C-i>
inoremap <C-l><C-k> <C-x><C-k>
inoremap <C-l><C-l> <C-x><C-l>
inoremap <C-l><C-s> <C-x><C-s>
inoremap <C-l><C-t> <C-x><C-t>


I would describe this below (in my answer to the question “Tell us about open-browser.vim, your enhancement of gx”).

Snippet system is a very primitive part for me for a development in a text editor. (BTW, other parts are Regular expression, Rectangular selection.)

Please google it :) Because seeing is believing.

star (*) command works only in normal mode. If you want to search a selected text in visual mode, you can use this plugin. However, I think Vim should provide it as a built-in command! If you want more features, see haya14busa/vim-asterisk.

This is a plugin like $VIMRUNTIME/editexisting.vim, or EmacsClient. They support: When a Vim instance is already running, in terminal, vim <file> opens a given file from arguments in the running instance. But this plugin has even more dedicated features to support it.

This can make operator-user.vim’s plugins completely repeatable. This plugin is Kana Natsuno version of Tim Pope’s repeat.vim. Please see the difference here.

A powerful grammar checker for Vim using LanguageTool. It is completely integrated to Vim. Wrong words / text are highlighted. And if you moved the cursor is on them, the below buffer shows a problem, context, correction. In fact, this is the first time to use this plugin and spell option for writing this interview! :)

For details, see the list of installed plugins in my dotfiles repository. By the way, the file is created by vivo.vim, a yet yet yet another vim plugin manager. The plugin is yet in development version. So I don’t want to talk about the details here. A package/plugin manager must be stable. And all specifications may be going to change from now. But the based policies in should not change so often.

I often discuss Vim plugin manager and its ecosystem with Shougo, the author of neobundle.vim and dein.vim.

What’s the most recent thing you’ve learned about Vim?

Many. But one small thing of what I’ve learned about Vim is listchars’s trail value (:help lcs-trail).

set listchars+=trail:-

This is very efficient option! It shows - for trailing whitespaces with a different color.

And, syntax plugins, indent plugins, filetype plugins, any other including $VIMRUNTIME seem to have many options not in help document. I’m setting the following configurations for runtime plugins.

" syntax/vim.vim
    " augroup: a
    " function: f
    " lua: l
    " perl: p
    " ruby: r
    " python: P
    " tcl: t
    " mzscheme: m
    let g:vimsyn_folding = 'af'

" indent/vim.vim
    let g:vim_indent_cont = 0

" changelog.vim
    let g:changelog_username = "tyru"

" syntax/sh.vim
    let g:is_bash = 1

" syntax/perl.vim
    " POD highlighting
    let g:perl_include_pod = 1
    " Fold only sub, __END__, <<HEREDOC
    let g:perl_fold = 1
    let g:perl_nofold_packages = 1

How did you get started writing Vim plugins?

I cannot remember so clearly, but I had known that vimtutor and built-in help is a great document to learn about Vim than blog entries on the web.

And the first plugin which I published to is CommentAnyWay.vim, the predecessor of caw.vim. Though it was very buggy for my poor Vim script skill then so I don’t want someone to use it now.

However, recently I haven’t released to because GitHub is a very comfortable place to develop a Vim plugin. I think this is a bad manner, I should release to also more often.

I wrote git-unreleased-vimplugins script in Perl before that checks if there are any plugins which is not uploaded to yet. But, well, recently, I don’t use the script :p

Tell us about open-browser.vim, your enhancement of gx.

open-browser.vim is one of the active Vim plugins which I’ve been working on. And also it is a long-living plugin in what I’ve created.

Vim is a text editor and not a shell or an Operating System (:help design-not). And Vim is good at cooperating with other command-line tools. But a web browser is GUI application, I can’t quickly view a content of a URL in a Vim buffer. That is the motivation why I’ve created it.

Recently, the required tools for web development become just a text editor and a web browser and a web server. And in some cases, we can develop even without the server-side. So I think that a cooperation with a web browser of a text editor will become more and more important.

And one of the examples of an excellent cooperation between a text editor and a web browser is Previm. It is a markdown preview system using only Vim and a web browser. A markdown text in Vim’s buffer is parsed by JavaScript (powered by marked.js). So there’s no need to install additional markdown command like pandoc. The required tools are just Vim and a web browser. What else?

If you installed Previm and open-browser.vim, you are ready to go. (You don’t need to install even open-browser.vim. But you have to set g:previm_open_cmd variable) And gratefully, Previm also supports mermaid, JavaScript library to generate diagrams and flowcharts from text.
You can sketch your idea from Vim!

Please see a GIF animation on GitHub for how it works.

You’re one of the main contributors to vital.vim. How would you explain the purpose of this plugin?

I will describe the based policies of vital.vim. I hope it also describes the main purpose why we wrote vital.vim.


The vital.vim’s license is very loose (NYSL, same as WTFPL). Because we would like to share our code without you having any concerns when you copy it to your plugin. If you feel embedding vital.vim to your plugin as a big deal, you don’t have to mind that you copy the code into your plugin, the only functions that you want. I also copy the vital.vim’s code if I feel a current writing plugin doesn’t fit vital.vim.

Vim plugin development workflow

Additionally, I think vital.vim has shown one of workflows when Vimmers write a Vim plugins in GitHub.

Developer Friendly

Personally, the most impressive feature is Changes file in repository and its specification because it is my idea. This file contains sections. Each section has a commit hash of git, module name(s), and a description of modules’ incompatible changes. And when you update vital modules of your plugin, vital asks if you really want to update it while showing the incompatible changes as of the vital version you installed before. Normally, in common sense, this is NEWS file rather than Changelog file. It is a confusing filename a bit. So we may be going to change the filename, though.

And also you can create an own vital.vim module because vital.vim allows creating external vital modules outside vim-jp/vital.vim repository. But I don’t use the feature and it seems to lack its document. We have to provide the information in Wiki or help document. Please hang tight if you want it! :)

Current users

Certainly, current vital.vim’s users are mostly Japanese. However, usevim posted a short blog entry about vital.vim before. Please try it if you get interested in. We are looking forward to hearing your honest opinions.

What have been the most useful resources for you to learn Vim?

Vim-jp. It is a Japanese community for Vim users / Vim developers / Vim plugin developers. Also I’m one of the members. The motto is “Teamwork by Publicity Stunt” (quote from TV animation “Ghost In The Shell:Stand Alone Complex”).

Basically, a community tends to be closed for other communities. But all of Vim-jp members have spirit in contributing to upstream, and outputting a useful information to Vim users. But, outside Vim-jp, sadly it seems they see Vim-jp as a closed community because of a language barrier. This is why I’m writing about Vim-jp community in detail now. And thank you Kevin for suggesting that :)

Vim-jp has all kinds of members. But all members love Vim. That the reason why (even each acts “publicity stunt”) it will be all right somehow.

Okay, okay, I love them all. and love Vim, too, of course!

Vim is just a text editor. But, if one text editor makes many people crazy and happy, don’t you think that is the really coolest thing, do you? :)

Share a snippet of Vim script you’ve written and talk about what it does.

I’ve written some Vim plugins and maintained it. And I also confirmed that those plugins are working on Arch Linux and Windows 7 64bit Pro now. And a few plugins are tested by Travis CI (Linux) / AppVeyor (Windows).

This allows opening URL under current in buffer quickly. This allows opening current word under cursor in buffer quickly. Also supports to open URL / word from command-line.

This allows opening current file on GitHub in web browser. This allows opening all issues / specific issue on GitHub in web browser. Also supports GitHub enterprise (Search entry in git config).

This plugin captures an output of Ex command and shows it in a buffer. :Capture map | map! | lmap shows all defined keymappings. :Capture !extcmd shows an output of external command. Of course, you can use :r! (:help :read!).

Opens the next or previous file in the same directory. Small but useful plugin.

One of the many many comment plugins. Supported almost languages. gcc toggles current line’s comment. See help for details.

It shows function name in statusline, and so on. Supported languages: C, Go, PHP, PL/SQL, Perl, Python, Ruby, Vim script.

Puts a current buffer to another Vim instance. Gets a buffer from another Vim instance.

However, I think channel and JSON feature included for the next Vim release is a really big news for me! If the feature is included, I think Vim plugins become thinner and become just an interface for external commands, or Web APIs, and so on! (But thinca has pointed out that we can’t use a new ch_open() function for Web APIs on https://. We cannot let go of curl yet, a swiss army knife :) ) Anyway, It is long-awaited feature for me, many Vim plugins should change its architecture.

Are you involved in a local Vim community?

I rarely attend to Vim meetings. And I haven’t given talks in such places. To be honest, I like a text communication than a verbal communication… ;) So please interview about that for other people :)

What have you been working on recently in Vim?

Vim plugins :) And I’ve been using AngularJS (it is very fantastic!) for both at work and for hobby programming. I don’t use Vim at work as I said, but of course I’m using Vim at home :)

(Sorry, this is not a recent talk though) Before, once I’ve written a small SPA application (at that time, no name was given like that) analyzing syslogs before for improving a daily work using ancient prototype.js :) Because all of engineers in office are ops side (server, network, …) so no development tools are installed, even runtime library such as JRE, and .NET Framework is too old. But all of them are using Firefox browser for primary. That’s why I’ve started writing SPA application then. I have struggled a lot against bugs about DOM states. Now, I have retired a server engineer there and become a system engineer. So I don’t know the SPA application is working now :) However, I should be able to write it in a solid way with AngularJS now.

Anyway, so I’m getting interested in a recent JavaScript movement and HTML5 application. That’s too slow response for the evolution of recent web technologies, though :p

However, Vim plugin and HTML5 application look resemble to me (oh, please don’t throw eggs at me). But one of the different things is that HTML5 application is very richer than Vim plugin… ;)

If you scroll down here because you feel tl;dr, I say simply, “I love Vim.”

Thanks for reading! :)