Vim script line continuation?

602 views
Skip to first unread message

Dasn

unread,
Mar 25, 2008, 6:25:57 PM3/25/08
to vim...@googlegroups.com
Well, it seems the new line continuation can be placed weirdly, which
will make the vim script syntax file even messy when considering the
line continuation. Any comments?

$ cat test.vim
e
\c
\h
\o
\ l
\e
\n("hello")
q

$ ex -Nu NONE -S test.vim
5

--
Dasn

Tony Mechelynck

unread,
Mar 25, 2008, 7:04:19 PM3/25/08
to vim...@googlegroups.com

So? You can also indent your scripts weirdly, e.g. reducing the indent
after an "if" command, or even messily, e.g. indenting your lines by the
result of tossing a 20-side die, regardless of syntax. To the best of my
knowledge, in neither case did anyone ever recommend it.

The vim-script syntax disregards all spaces and the preceding linebreak
preceding a backslash which is the first non-blank on a line; it also
disregards indenting (which is only there to make the script more
readable to human people). That doesn't mean there is no such thing as
"good script writing style", which would be stricter than going by
anything the parser would accept. In the same way, it _is_ possible to
write C or CSS by removing all indent, all comments, all "unnecessary"
spaces, and filling the lines to, let's say, the longest possible length
shorter than 160 characters; the C compiler or the browser won't give an
error, but I would never call that "good" programming style.


Best regards,
Tony.
--
Too often I find that the volume of paper expands to fill the available
briefcases.
-- Governor Jerry Brown

Ben Schmidt

unread,
Mar 26, 2008, 12:30:53 AM3/26/08
to vim...@googlegroups.com

And indeed, it is worth posting the link for those who are not already familiar
with the International Obfuscated C Code Contest.

http://www.ioccc.org/

Cheers,

Ben.


Matthew Winn

unread,
Mar 26, 2008, 4:32:22 AM3/26/08
to vim...@vim.org
On Wed, 26 Mar 2008 06:25:57 +0800, Dasn <da...@lavabit.com> wrote:

> Well, it seems the new line continuation can be placed weirdly, which
> will make the vim script syntax file even messy when considering the
> line continuation. Any comments?

Placing the line continuation on the end of the preceding line
wouldn't work because something like
:n C:\Windows\
is a legitimate Vim command. Using the start of the following line
instead is a good and unambiguous alternative.

Vim isn't the only program to use start-of-line continuations: RFC822
(email and the like) headers use whitespace at the start of a line to
indicate that the line is a continuation of the line above.

--
Matthew Winn

Reply all
Reply to author
Forward
0 new messages