How I

Fatih Arslan

Software engineer and open source developer

Ankara, Turkey

Who are you and what do you use Vim for?

I am Fatih Arslan, a Software Engineer working remotely from Ankara, Turkey. My main interest area is about distributed systems and developer tooling. I’m currently working for the Delivery team at DigitalOcean.

I’m using Vim since 2002. I was a high school student and wanted to improve myself. I don’t know how but I think somehow I’ve discovered that there was this thing called ‘Linux’ and it would force you to improve yourself. I’ve found out that Debian was very popular. So back then every day I’ve was at home coming from school I had two things, first dealing with Debian and learning how to use Linux. Second, I’ve started to use Vim and was trying to learn it (it was really very difficult for me because I had a very limited internet connection, so there was no way I could search and ask for help like we do nowadays.)

Because of my interest for Linux I’ve achieved to get an internship and eventually started working for Pardus Linux. Pardus Linux was a government funded project and was intended to be an easy to use Linux Distribution(even Ubuntu was not popular back then!). I was a package maintainer and was developing features to improve the UX for our users (such as picking up the correct graphic driver). My main job was maintaining our X.org related packages. This meant that most of the time I didn’t have any kind of GUI to work with while I was updating and fixing bugs (no XServer!). All my work was on Terminal. Because I couldn’t open any kind of GUI, my tools and apps were command line apps. I had mutt for e-mails, irssi for irc/chat, mpd for music and Vim for all the rest.

I use Vim for everything. I use it for writing blog posts, editing scripts, taking notes (still trying to find a good solution), developing code, etc… But I use Vim mainly for projects written in Go. vim-go was born because I wanted to get faster and be more productive (more on that below).

Because of vim-go I use both Vim and Neovim (trying my best to support both). On Mac OS X, MacVim is still the fastest way of using Vim (scrolling for example) as the rendering of iTerm2 just is not as fast as the Linux equivalents. I’m actually a very long user of MacVim, but Neovim’s async feature was so good that I’ve just started to use it. But I still jump and use occasionally Macvim(). I mostly follow HEAD for both projects and install it via brew.

Introduce us to your Vim config.

My vim config is public and is highly commented (so I don’t forget what I’ve did). I’m maintaining it and change it a lot (such as replacing a plugin, changing settings, adding a new map, etc..). The most important part of my plugin is that it works for Vim, MacVim and Neovim at the same time. This is very important as I’m trying to give the best user experience in vim-go. So I want to make sure vim-go works well on every platform.

I don’t like to split up my vimrc into multiple files or folder. Because it makes it easier to maintain and I just drop it and it works (supposed vim-plug is installed of course).

I’m using vim-plug to organize my plugins. vim-plug is also maintained and is Neovim compatible, so it downloads and updates all my plugins asynchronously. Also it makes it easy to load/unload plugins based on which editor I use (Vim or Neovim).

Options

Because of my history of using Macvim for a long time I have a dedicated section for customization and making it more usable. I like that I can just check with the has() function which Vim version I use. So my config is arranged like:

if has("gui_macvim")
	// macvim specific setting
else
	// vim specific
endif

For me speed is very important. Best way of speeding up editing is crippling down syntax highlighting. That’s why I have some settings to make syntax highlighting less featured:

set nocursorcolumn       " do not highlight column
set nocursorline         " do not highlight line
syntax sync minlines=256 " start highlighting from 256 lines backwards
set synmaxcol=300        " do not highlith very long lines
set re=1                 " use explicit old regexpengine, seems to be more faster

I use :help a lot. But I don’t like that it opens in a split (it’s not much useful because of widescreen). That’s why I was using it always like:

:vert he topic

But I’ve started to use vim-scriptease which has the wonderful K shortcut which opens the :help for the word under the cursor. So I’ve added this line to my config:

autocmd FileType help wincmd L

Now :help and K both opens the help pages in a vertical split.

I also search a lot so I have a couple of improvements. When I search for something and jump with n or N it doesn’t center my view. So I’ve added the followings to make it more usable:

" Search mappings: These will make it so that going to the next one in a
" search will center on the line it's found in.
nnoremap n nzzzv
nnoremap N Nzzzv

Sometimes I also like to select a piece of code and want to search it. Here * doesn’t work well. So I’m using the following piece which makes selected pieces of characters more easier:

" Visual Mode */# from Scrooloose {{{
function! s:VSetSearch()
  let temp = @@
  norm! gvy
  let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g')
  let @@ = temp
endfunction

vnoremap * :<c-u>call <sid>vsetsearch()<cr>//<cr><c-o>
vnoremap # :<c-u>call <sid>vsetsearch()<cr>??<cr><c-o>

Plugins

I like well defined and good maintained plugins. I try to minimize my need for plugins but it’s hard to resist. I add/update or remove plugins very often according to my needs. My most used plugins are:

I use ctrlp a lot. I also want to try unite.vim but didn’t have the time to try it. For ctrlp I think the most I like is the use of dynamic tag creating. What does it mean? For example I have this setting in my config:

let g:ctrlp_buftag_types = {'go' : '--language-force=go --golang-types=ft'}

and have a file ~/.ctags with the content:

--langdef=Go
--langmap=Go:.go
--regex-Go=/func([ \t]+\([^)]+\))?[ \t]+([a-zA-Z0-9_]+)/\2/f,func/
--regex-Go=/type[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/t,type/

Now it doesn’t matter which Go file, it dynamically populate the list when I call :CtrlPBufTag with all the functions and types in that file. So I can easily jump to it. The best part is that you don’t create any kind of tags file as it’s all dynamic and on the fly!

Most recently I’ve changed my completion plugins from YCM to deoplete/deoplete-go with neosnippet. As of today it’s a joy to use it. It’s still slow though but Shougo said he want’s to improve the state of deoplete.

Color scheme

I’m using molokai. I just like it too much. But I’m thinking to switch to a grayscale theme soon and want to see how it work out for me. (I didn’t decided which one, if none exists I’ll probably create one)

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

For Vim itself I think nothing can beat :help. Even after years you always find something new and it’s just mind blowing.

For VimL I like Steve Losh’s excellent tutorial “Lean Vimscript the Hard way”. But I learn VimL mostly by reading the source of other plugins. It fits my style of learning better because I can break it in pieces an run it again. I can test it by trial and error so I like it more.

I also read occasionally from /r/vim on Reddit.

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

You know, you never stop learning something from Vim :) These are the most recent things I’ve learned:

How did you get started writing Vim plugins?

I’ve wrote my very first vim plugin while I was working at Pardus Linux. The plugin was speeding up our day to day tasks we’re doing while maintaining our packages. It immensely improved our productivity and I could see the power of plugins in Vim.

Beside that plugin I usually was a consumer of plugins but I’ve tried occasionally to contribute to some if I could.

Right now when I want to write a new feautre or seek for something I first check if tpope or Shougo has written something already. If not I’ll just try to write a simple function in my config (no plugin). I don’t have any other vim plugin other than vim-go that I maintain. Because vim-go takes a lot of time to maintain already and I also have many other open source projects written in Go. So there is little time.

When I started writing Go in 2012 (in my previous job at Koding), the state of vim was not improved as it was today. The Go developers had created already a great initial plugin and it was part of the Go source code, also called misc/vim for those who know it. But even though I really like Vim, it was not pleasant to use. Because beside misc/vim, I had to install other tools and the necessary dependencies. But there was some flaws with this setup that made me uncomfortable:

So it was frustrating for me and I thought I can create something based on all these pieces and make it more easy to use. So I’ve created a repo and put all these stuff into this repo.

I’ve started then to improve it and make it a idiomatic Vim plugin. I’ve added custom mappings, configurable settings across the whole project. I’ve added doc.txt, so :help would work for the current set of features. From there I’ve started to add new commands, such as :GoBuild, :GoRun, etc.. which was one the earliest features. I improve the Windows support with the help of windows users.

After I’ve announced it on the GopherAcademy two years ago, people started to use it. And I remember some of the users saying to me how easy it was to set up Vim to work with Go. That made me really happy.

Another reason why people adopted it was because misc/vim was eventually removed from the official Go repo. My initial idea was contributing back all my changes to the Go project. But when they ditched it, I’ve just continued to work on vim-go. Because it was and is still hosted on Github, it was easier for people to contribute. In the beginning there was not much contributors, but with the popularity of vim-go in last year, I’ve seen a lot of contributions.

Right now vim-go has over 4249 stars with 115 contributors contributed with over 250 pull requests. 22 issues are open (which only 5 are bug!). As you see it’s very stable and I’m really proud of that. I’m very actively maintaining and fixing the bugs.

Today vim-go is the de facto plugin for Go programming language. People just love it. I’ve seen many many converts from other editors just because of vim-go! I think this is something we can be proud of :) Also I think part of why it was so successful is because of the great tooling we have in Go ecosystem.

vim-go is developed in my spare times. Even though we have some contributors, there are no main contributor other than me. So this takes some time of mine. I’m spending each weekend approximately 4-5 hours for bug triaging reviewing the PR’s and implementing features. There are times where I’ve spent even more (~10 hours), but sometimes I’m not doing anything (like when I’ve started a new job this year). Because of that it takes a some time to merge a PR occasionally, but I think it’s Ok. It’s my hobby project and I think so far I’ve done a good job maintaining my work-life balance here. Also the vim-go community is very helpful and appreciate the work we’re doing. So I also want to thank from here to all the contributors and users of vim-go!

For the future I want to tackle one the long standing issues we have: tests integrations! Vim-go doesn’t have any kind of tests and it’s really makes me sad to see that. I want to freeze it for a version (no features) and want to only implement tests and improve the current codebase. I’m already refactoring from time to time to make it maintainable. But because of the lack of tests it’s hard to move forward.

I also have a secret project that I’ve started recently. It’s a very alpha and I’m experimenting with it. Because there is not much to show I’m keeping it in my local branch. If I believe it’s a good feature, I’m going to convert if from a prototype to a full featured project and integrate it into vim-go.

Are you involved in a local Vim community?

I’ve never attended a meetup (because there doesn’t exist any here in Turkey). But I would like to attend or share some of my knowledge if possible in the future. I gave a talk last year in DotGo (Paris 2015) about Go Tooling. I’ve showed all the examples in Vim with my vim-go plugin and people really liked it.

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

I’ve recently started to use deoplete.nvim with deoplete-go. I also wanted to use neosnippet as it was a nice plugin.

I’m using tab for cycling over the items in a completion menu (instead of c-n). But I also use tab when there is no completion menu to expand a snippet, and jump to the next placeholder inside the snippet. So the tab key needed some love:

function! s:tab_complete()
  " is completion menu open? cycle to next item
  if pumvisible()
    return "\<c-n>"
  endif

  " is there a snippet that can be expanded?
  " is there a placholder inside the snippet that can be jumped to?
  if neosnippet#expandable_or_jumpable() 
    return "\<Plug>(neosnippet_expand_or_jump)"
  endif

  " if none of these match just use regular tab
  return "\<tab>"
endfunction

imap <silent><expr><TAB> <SID>tab_complete()

Now whenever I use tab in insert mode it dynamically changes based on the context and where my cursor is. I can use tab to cycle items in completion menu, but also uses it to expand a snippet or jump to next placeholder inside the snippet. I think this is an example that shows the power of Vim’s mapping feature combined with VimL.

What have you been working on recently in Vim?

I’m a part of the Delivery team in my new job at DigitalOcean. Our team is responsible of creating and improving the current internal tooling. Lucky for me, most of our projects are written in Go. So because of vim-go its already something I’m used to it.

But we also use Chef extensively and I had the experience to write some Ruby. And the tooling around Ruby is also great in Vim so I didn’t had much problems adapting myself to this new environment.