- To change (once) to the dir of the current file
:cd %:p:h
Nice.
But I'm not going to remember it until I understand it.
I scoured the :help files but couldn't find and explanation of the
syntax.
:p is short for :print and :h is help.
So there's two things I don't know:
1. The symbolic (?) language you are using - the same that's used when
scripting vim, I would imagine.
If you're impatient, full details can be found at
:help filename-modifiers
2. How to use vim's help efficiently
There are several attacks one can use to get Vim's help to spit
out helpful stuff. In this case, I found it by typing
:help :p
and then hitting control+D instead of <enter> which causes Vim to
show auto-completion for what you've typed so far. This brought
back 6 columns of 11 rows each of possibilities, but most of them
were clearly not what I was looking for (there was something
after the ":p"). The one that looked most promising was "::p"
which, though somewhat strange-looking, turned out to be what I
wanted.
Another attack might be to use
:helpgrep :p
:copen
This opens a quickfix window (":help quickfix-window") of all the
hits in the help where ":p" appears in the help. While I get
just shy of 400 hits back, there are some obviously good leads
and some obviously bogus leads among the chaff. One of the nice
things is that you can use regexps in your search, so you can
change it to
:helpgrep :p\>
to winnow that list down to 47 according to the help I have here.
A number of the top hits come back in cmdline.txt, all fairly
clustered together, so any of them would be a good starting
candidate. Just navigate to a prospective candidate and hit
<enter> to jump to that piece of the helpfile.
These two methods are my usual attack into finding something in
the vim-help. If these don't get you to where you want to go,
it's often a matter of finding the right search keyword/pattern.
I've been stumped by this before (just this month) and the
mailing list is quite friendly about answering questions as well
as guiding you in with keywords. In my case it was finding what
turned out to be ":help i_CTRL-G_u" and Yakov was able to dig it
up in the help using the phrase "break undo" which I hadn't come
up with.
So dig a bit with the above tools, and if you hit a wall, drop a
line on the list with what you want and what you've tried, and
I'm sure you'll get all sorts of good answers back.
-tim