– we create awesome web applications

Boris recently purchased iA Writer to edit Markdown, which is our primary format used internally for readmes, proposal documents, contracts etc.

iA Writer looks very nice indeed. The typography is beautiful, and I especially like how it outdents headings and lists:

Ai Writer Formatting Example

Still, I can’t help but find it impossible to do any serious text editing without the full Vim power by my side.

So I decided to try to at least approximate the experience of using iA Writer with Vim.

It turned out you can make the text look pretty decent by using a good font and bigger linespace. The “outdent” is out of the question of course (if anyone knows how to accomplish it I’d be very glad to hear that), but the rest is actually pretty good, with some extra formatting for lists, links etc.

I don’t like the ‘focus mode’ in iA Writer, so I didn’t try to replicate any of this, and not sure if its possible. Instead I use a different background color for the current line. Here is the result:

Vim Formatting Example

As you can see its not bad ;), and its Vim!

I’ve put the config into ~/.vim/writer.vim file that I can ‘:source ~/.vim/writer.vim’ when I’m working with Markdown:

set background=light
set nonu
set laststatus=0
colorscheme default
hi FoldColumn guibg=white
set foldcolumn=12
set linespace=8
set guifont=Source\ Code\ Pro\ Light:h20
set tw=80
hi Normal guibg=gray95
hi NonText guifg=gray95
hi FoldColumn guibg=gray95
hi CursorLine guibg=gray90
hi Title gui=bold guifg=gray25
hi MarkdownHeadingDelimiter gui=bold guifg=gray25
hi htmlSpecialChar guifg=black
hi markdownBold gui=bold guifg=gray25
hi markdownItalic guifg=gray25 gui=underline
hi markdownUrl guifg=#2fb3a6
hi markdownAutomaticLink guifg=#2fb3a6
hi markdownLinkText guifg=#317849
hi markdownUrlTitle guifg=#317849
hi markdownBlockquote guifg=#317849 gui=bold
hi markdownId guifg=#2fb3a6
hi markdownIdDeclaration guifg=#317849 gui=bold
hi markdownListMarker guifg=#317849
highlight Cursor guibg=#15abdd

My Vim-fu improved a lot in the last couple of years.

Part of the reason is that working on dotvim forced me to dive deeper into it, but thats not the whole story.

I think a much bigger reason is that I decided to systematically work on improving it.

One of the tricks I use is to have a list of Vim tricks and shortcuts that I’m learning right now on my OSX dashboard.

Whenever I come by a new shortcut or trick I add it to the list. Once I feel like I learned it and added it to my regular tool-belt I remove it from the list.

The current list looks like this:

]p - paste with indent
n| - to n-th column
&  - repeat subst
g& - global repeat subst

Regarding n| I don’t know how I got this far w/o knowing it ;). n means any number, e.g. 5| or 37|, which would go to column 5 and 37 respectively.

I use nG all the time to get to line number n, so naturally it should have been clear to me that there is a horizontal equivalent to it, but no, I just stumbled on it by ‘mistake’ a couple of days ago.

Once I add something to the list I try to use it as much as possible in the next days, until I feel I know it well enough that I actually remember it exists and use it during regular text editing. Once it happens, I remove it and replace it with something else what I just found or things I know but feel that I don’t use enough.

In the coming weeks I’ll try to write a semi-regular short posts here about new nice Vim things that I find. I have enough content for a while just talking about all the great stuff in dotvim ;).

But first lets start with some basics.

If you don’t yet understand the DNA of Vim, how most its commands are verb + motion, then go and read this first: “Your problem with Vim is that you don’t grok vi”. Note that the guy eventually gets to pretty advanced Vim that you don’t need at the beginning, but read it anyway, even if only to know what is possible once you really master this great editor.

This is another introduction into the verb+motion nature of Vim: “Why, oh WHY, do those #?@! nutheads use vi?”.

It is a little more beginner friendly, but a little less coherent too.

“Everyone Who Tried to Convince Me to use Vim was Wrong” is another nice article from Yehuda Katz of Rails fame where he talks about how own road to Vim.

He describes a more incremental approach of staying mostly in the insert mode for a first couple of days until you learn native Vim ways to do things. Especially, if you use MacVim, gVim or another Vim wrapper that provides you with all the regular operating system keyboard shortcuts like ⌘S for save and ⌘W for close etc. I didn’t do it this way myself, and I remain slightly skeptical as to the premise, will be glad to hear some success/failure stories in the comments.

I agree though that I would definitely not recommend disabling arrow-keys until you are already semi-pro.

Now once you’ve read all this and ready to dive in, I recommend you do go and install dotvim as it packages lost of very useful settings and plugins that will make the experience much better. Just follow the “Installation” section of the README.

If you want to read some more, here you go:

Also you can browse and follow my Vim bookmarks here.

UPDATE 10-Dec-2012 This article was translated to Serbo-Croatian language by Jovana Milutinovich from Webhostinggeeks.com.