martin carpenter

contents

most popular
2012/05/05, updated 2012/12/15
Ubuntu unity lens for vim
2010/04/14
ckwtmpx

ubuntu unity lens for vim

2012/05/05, updated 2012/12/15

tags: ubuntu vim lens

github home http://github.com/mcarpenter/unity-lens-vim
repository URLs https://github.com/mcarpenter/unity-lens-vim.git
git://github.com/mcarpenter/unity-lens-vim.git

about

Ubuntu's Unity desktop offers Lenses: fast, programmable HUD finders for files, URLs or any other sort of object that you can imagine. You can bring up the finder window and lenses by (left or right) clicking the "dash home" Ubuntu icon top left of your desktop, by tapping the "super" (windows/mac) key or with Alt+F1, Enter or Alt+F1,→.

This vim lens searches your vim editing history (~/.viminfo) to allow you to quickly open recently edited files (sorted by most recently opened) or files anywhere on the filesystem. It supports glob(3)-like wildcarding (~, ?, *) and regex-style anchors (^, $) in search expressions.


setup

Install gvim:

alice@ubuntu:~$ sudo apt-get install gvim

Install the latest unity-lens-vim package:

alice@ubuntu:~$ sudo apt-get install https://github.com/downloads/mcarpenter/unity-lens-vim/unity-lens-vim_0.0.2_all.deb

Log out and back in again (to ensure the lens daemon starts) and then tap Super+e ("e" for "edit") to open the lens.

vim setup

Ubuntu's defaults are sane: you shouldn't need to do anything here.

The vim lens determines your editing history by looking at the mark history in ~/.viminfo. Even just viewing a file in read-only mode sets the "last position" (") mark so this works quite well. The :set viminfo command can be used to configure vim's history length and other characteristics. The viminfo documentation can be read from within vim with :help viminfo.

I like gvim to open maximized. To enable that, you can use the CompizConfig Settings Manager. Run ccsm, enable the Window Management plugin and maximize class=Gvim in the rules.

searching

Wildcarding uses glob(3) or fnmatch(3) style, not regular-expression or PCRE wildcards. Use ? to wildcard a single character and * to wildcard any number of characters (including zero). As the first character of an expression before a slash ~ means "my home directory", whereas ~joe means "user joe's home directory". A tilde anywhere else than the first character is literal. The search expression applies at any point in a .viminfo path, so searching for /bin will potentially both match /bin, /usr/bin, ~/bin, ... Consequently you may anchor the start of a search with a caret, eg ^/bin. Similarly the end of a search expression can be anchored with dollar so that eg *.c$ will search for C but not Clojure (*.clj) source files. To search for or create files on the filesystem you must start the search string with a leading slash.

hacking

The lens is written in python leveraging Ubuntu quickly(1). It can be installed and run from the git repository source:

alice@ubuntu:~$ sudo apt-get install quickly quickly-unity-lens-template
alice@ubuntu:~$ git clone https://github.com/mcarpenter/unity-lens-vim.git
alice@ubuntu:~$ cd unity-vim-lens
alice@ubuntu:~$ sudo quickly install
alice@ubuntu:~$ quickly run

The lens then runs in the foreground and you can use print for simple debugging. The action happens in __init__.py. To run the unit tests:

alice@ubuntu:~$ quickly test

todo

see also