I am a real Vim user today

Thursday, January 10, 2013

There comes a point, usually after you've been using something for awhile, when you realize you are no longer just using it casually. And no, I'm not talking about drugs.I'm talking about defining my first shortcut key in my .vimrc.

A little background

I was first introduced to Vim by my Hacker School buddy James. For those of you who don't know, Vim is a very peculiar text editor. It is an "improved" version of Vi, the de facto Unix editor. Vim allows for a very efficient coding experience in which your hands generally never have to leave their main resting positions on the keyboard. And unlike editors (see Emacs), Vim makes heavy usage of different input modes to separate document navigation, inserting content, and text selection. This makes for a steep initial learning curve, as the default mode in Vim is mostly navigational, which is a farcry from the style of most word processors (hjkl actually mean hjkl, not left down up right).

Word Wrap

So I was excited to be able to write these blog posts using Vim since I've gotten quite good and fast at using it. However, I quickly realized that a text editor that primarily displays lines of code needs a bit of work to properly display words and sentences.

For instance, here's what I was seeing everytime I wrote a paragraph of text:

This is a medium paragraph of text. Everything is all fine and dandy until you
 get to the end of the line. Then, whatever text you just wrote gets cut off p
recisely when you reach the column width of your Vim window. This leads to awk
ward and hard to read paragraphs!

So, after a bit of research, I threw this into my .vimrc file.

" F5 word wrap mode (great for writing blog posts!)
set wrap
nnoremap <F5> :set linebreak<CR>
nnoremap <C-F5> :set nolinebreak<CR>

The first line turns the wrap option on. The second line binds :set linebreak<CR> to F5 in normal mode. The last line binds the reverse to Ctrl + F5. <CR> is a carriage return, otherwise known as the enter or return button.

So hitting F5 in normal mode effectively types out :set linebreak then hits enter for you, rendering much more readable text for when you are not just writing code!

This is a medium paragraph of text. Everything is all fine and dandy until
you get to the end of the line. Then, whatever text you just wrote gets cut
off precisely when you reach the column width of your Vim window. This
leads to awkward and hard to read paragraphs!

For those of you that are curious, Vim will automatically break the line as soon as it encounters any of these characters ^I !@*-+;:,./?. You can change that default by redefining the breakat option. See here for details.

.

[vim] [vimrc] [shortcut] [emacs] [word wrap] [blog] [hacker school]

Programming Resolutions

Wednesday, January 02, 2013

Last year was the first year in a long time that I did not make any resolutions over the year. I’d like to get back to it this year, with a few that I should be able to keep.

  1. Articulation: 100 posts about programming things I’ve encountered and want to share.
  2. Get involved: Contribute a couple patches or a bug fix to an open source project.
  3. Push myself: Do a weekend project and get it on the front page of HN.
  4. Read more books: I need to expand my knowledge beyond just reading the news and blogs.

Here’s to a great 2013!

.

[resolutions] [2013] [2012] [programming] [open source] [blog] [weekend project] [hacker news]

Page 1 / 1