2012/05/05, updated 2012/12/15
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 |
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.
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.
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.
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.
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
fnmatch()
doesn't support escape characters so there is
no way to search for literal *
or ?
characters. (This is not a
significant problem since non-literal *
or ?
match their literal
equivalents...).quickly(1)
.