cga2000 wrote:
On Sun, Feb 25, 2007 at 07:57:39PM EST, A.J.Mechelynck wrote:
[..]
- 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.
Not here. Here they are |filename-modifiers|
When used as a file name:
% means the current file
let's say projectfoo/foobar.txt
%:p means (the current file) expanded to a full path (from :p = "path")
let's say /home/johndoe/projectfoo/foobar.txt
%:p:h means (the current file expanded to a full path) minus the last
component (from :h = "head")
let's say /home/johndoe/projectfoo
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.
yes
2. How to use vim's help efficiently
:-)
here are a few examples; some of them use a fictional "subject":
:help
gives you very general help. Start scrolling and you will see a list of all
known helpfiles, including those added locally (i.e. not distributed with Vim).
:help subject
gives you help about some subject, which can be (the list is
not exhaustive):
:help :subject
an ex-command, for instance the following:
:help :help
help on getting help
:help 'subject'
an option
:help subject()
a function
:help -subject
a command-line option
:help +subject
a compile-time feature
:help EventName
an autocommand event
:help abc
a normal-mode command
:help CTRL-B
a control key in Normal mode
:help i_abc
:help i_CTRL-B
the same in Insert mode
:help v_abc
:help v_CTRL-B
the same in Visual mode
:help c_abc
:help c_CTRL-B
the same in Command-line mode
:help user-toc.txt
table of contents of the User Manuel
:help digraphs.txt
the top of the helpfile "digraph.txt"
similarly ofr any other helpfile
:help pattern<Tab>
get a helptag matching /pattern/
If 'wildmenu' is ON, the last one above will (if there are at least two
matches) replace the bottom statusline by a menu. Navigate with <Left>
<Right>, move up or down directory trees with <Up> <Down>, accept with
<Enter>, abort with <Esc> -- see ":help 'wildmenu'" for details
:help pattern<Ctrl-D>
see all possible matches at once
:helpgrep pattern
search the whole text of all helpfiles for the given pattern. Results are
built into a "quickfix error file" and can be viewed with
:cn
next match
:cprev
or
:cN
previous match
:cfirst
:clast
first or last match
:copen
:cclose
open/close the quickfix window
But, like a dictionary or an encyclopedia, the Vim help system also lends
itself to "reading by the Montecarlo method" and to "the dictionary game":
- Montecarlo method: start anywhere and read what you find there. Read on.
When bored, open another page at random.
- the Dictionary Game: Start by the Montecarlo method. When you see a subject
name (here anything in dark green) with which you are not familiar, look it up
(here: double-click it or hit Ctrl-] on it). Repeat until bedtime.
Thanks,
cga
My pleasure.
Best regards,
Tony.
--
Saturday night in Toledo Ohio,
Is like being nowhere at all,
All through the day how the hours rush by,
You sit in the park and you watch the grass die.
-- John Denver, "Saturday Night in Toledo Ohio"