miércoles, 25 de marzo de 2009

Fully vim style linux - Part 1

That's the start of a group of threads related to converting your linux experience to the most vim-ish way.

My aim is to get every application I use behave as vimish as possible.

That means:
  • Understand hjkl
  • Being able to find using '/'
  • Maps or at least some kind of extensibility
  • If we can't go vim, let's go screen, or even emacs ( keyboard >> mouse )
My use cases are the typical ones for any programmer and internet surfer:
  • Editing text
  • Browsing
  • Reading pdf's and chm's
  • Playing music (local mp3 or streaming)
  • Chat (IRC, msn)

Editing text with vim

First things first. If you want vim shortcuts everywhere, you should first learn vim deeply. That means getting used to hjkl, mappings, trying plugins and so.

There are some plugins that are a must, if you ask me. For example:

  • snippetsEmu or snipMate
  • parenquote
  • surround
  • pastie
  • FuzzyFinder or 0scan
there's plenty of info about vim in the net, so I'm not going to rewrite what's been already written. Only two little tips for your .vimrc

:nnoremap ,vimrc :new ~/.vimrc
:nnoremap jk <esc>
A 'quick' shortcut to edit your vimrc when you think: "Oh, that map is darn cool, I must have it in my vimrc". Just press ',vimrc' and you have your vim config file ready to edit.
The second one is pretty obvious, but it's one of the coolest tricks I've seen. No more pressing escape to go to the normal mode.

Browsing
If you're short on resources, use opera. Calmar has a pretty nice opera config file for vim keybindings in his page
For those using firefox, you MUST use vimperator. It's the reason why I switched from opera to firefox. With vimperator, your firefox will be really close to vim. You can use the common navigation shortcuts (hjkl, gg, G, c-o, c-i ,c-d, c-u, c-b, c-f), and it allows some cool way of navigate the web. For example:

  • gu : 'go up' . loads the url you're on from the start till last '/'. That means, travelling one directory up if you're browsing an ftp. http://www.foo.com/bar/lala/baz.html -> gu -> http://www.foo.com/bar/lala/
  • gU: 'go (really) Up' . Loads the main page on the server. From the begining of the url till the first '/' .
  • [[ and ]] are for traveling through document hierearchies. Hey ! that's my patch! . If you're browsing a document written with latex2html, or there's a link with the text 'prev','previous','<' or '<<' ,or their obvious counterparts, [[ and ]] will load the page pointed by them.
  • f. It activates the 'quick hints' mode. Typing substrings of text links, or the number assigned to a given link, it vimperator will load the given page when the typed string points to only one. F does the same but opens it in a new tab.

Vimperator is very customizable, with a plugins system and a vimperatorrc file that's read when you run vimperator. Tips:

:noremap ,vimrc :!gvim ~/.vimperatorrc
:noremap <Left> gT
:noremap <Right> gt
Pretty obvious, right?

type :h in vimperator to see a quick tutorial and the docs.

Cya

No hay comentarios: