Skip to content

VimL heredoc (<<HERE) for user commands #7638

@ZyX-I

Description

@ZyX-I

Currently if one wants to emulate :python with user commands he will be stuck at implementing << EOF: there is no way for user commands to have multiline input, except for not adding -bar and using :execute 'MyCmd' "multiline\nstring". On the other hand it is impossible to just add command -herestring and expect it to work fine: not unless somebody wants to state that user commands must be defined not prior to its usage, but prior to its appearance (i.e. prior to the first function definition which happens to have that command inside) and can’t switch definition after that (or give up on having proper parser). Thus the suggestion: knowing that python << EOF\n{multiline string}\nEOF yields just the same result as execute 'python' "{multiline string}" I am suggesting to add :here command used like that:

here MyCmd << EOF
foo
EOF

and

if 1
  here! MyCmd << EOF
    First non-empty line appears as having zero indent when bang is used.
   And this appears as an error for it being less indented then the first one.
  EOF
endif

. The only thing which :here command will do is calling MyCmd with multiline string in <args>, universally and without requiring any additional support in MyCmd definition.

Additionally :here may accept range and forward it to MyCmd. Also :here! is good for built-in :python itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions