You are here
Vim file exploration tips
Liraz Siri - Mon, 2011/05/23 - 09:06 -
7 comments
Find filename patterns
Using Vim's built-in file explorer, it's possible to find specific filenames by pattern. For example:
# :Ex is short for :Explore # search all subdirectories :Ex */Makefile :Ex */*.c # search recursively :Ex **/Makefile :Ex **/*.c :Ex **/*tpl*
This will take you straight to the first match. If you want the next match after that:
<Shift-DownArrow>
And back:
<Shift-UpArrow>
Bookmarking locations in the filesystem
When I use sshfs to mount a development VM's filesystem I sometimes find it tedious to type in the same long sub-directory paths over and over again. I've been setting up symbolic links to make my life somewhat easier but that gets tedious quickly too.
So I searched Vim's documentation a bit and it turns out that Vim's file explorer allows you to bookmark locations in the filesystem like this:
{cnt}mb # make bookmark {cnt}gb # goto bookmark q # list bookmarks
For example:
1mb # set the first bookmark 1gb # go to the first bookmark
Quite handy.
Comments
(Almost) makes me want to start using Vim!
I did try Vim when I first started testing out Linux but it seemed so counter-intuative to me that it was a pain. I remember reading that it is actually better (for some reason why which I don't recall anymore but seemed to make some sense) but that was irrelevant to me at the time.
So at the end of the day familarity won over and I've been a happy nano user ever since. I find nano to be pretty much a Linux commandline version of MS Notepad!
After reading this post (and a couple of other bits here and there) I'm thinking I probably should have another look at Vim sometime soon. Part of my problem is though that although I use Linux exclusively at home, at work I use a combo of Linux and Win. It sometimes feels like anything new or too different causes (at least short term) productivity losses.
Vim is much more powerful than Nano
I'd be interested to hear more
It all sounds very interesting and I'd love to hear more about it. I'll definately have to have a bit more of a look and play with Vim and see if I can get my head around it.
I use vim-full
The default vi program has some strange behaviour on Ubuntu and Debian from my experience; to fix this, I install vim-full. I have never figured out the difference. Would anyone know?
Chris Musty
Director
Specialised Technologies
Pages
Add new comment