Thursday, August 4, 2011

A few questions about :append and ex

1) If I understand right, :append is used this way
:append
line1
line2
.
and . means end, in a similar way as
cat <<EOF
line1
line2
EOF

What could I do if I want to insert a line containing only a point.
I don't really need this but I'm curious ;-)


2) With the cat example above, it's possible to write things like
cat <<EOF
$var
line2
EOF

Has vim something similar (by default not it seems)?
And is there a better solution than
:execute "normal o" . var . "\nline2"
to handle this case?


3) I've just read in the documentation that if 'cpo' option doesn't
contain C,
:append
a
\b
.
would write
ab
because the \ is understood as line continuation.
I have cpo=aABceFs (the default configuration, on my computer)
But I obtain
a
\b
(actually C or not does not seem to change anything, do I miss
something?)

4) and a last one about ex use
It seems that one uses ex in the following way

ex file <<EOF
%s/pattern/replace/g
w
EOF

a) In this case, I do not write wq or x at the end but w and it seems
to work. Is it cleaner (necessary ?) to add :q as last line, or is it
implicitely added.

b) Has ex an option such as -s (meaning string) so that a sh user
could write the previous example this way
sh -s '%s/pattern/replace/g | w' file
(bash or zsh users can already use <<< for this, but I need sh in my
case). What I don't like about ex ... <<EOF, is that it looks weird in
an indented script (the here document must be stuck to the left margin it
seems)


Ranousse

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: