Multi line `execute-keys`

Hello,
When I try to break a line inside a execute keys I get error:

 execute-keys '!lua -e "
        a = 'foo';
        io.write(a);
        "<ret>'

Is there a work around ?

Your issue is to not double-up the single quotes.

echo 'a''b'

It is recommended however to not pass complex strings – such as a script – to execute-keys, because of the key interpretation.

# Save the shell command register
evaluate-commands -save-regs '|' %{
  # Set the shell command to execute
  set-register | %{
    lua -e '
      a = "foo"
      io.write(a)
    '
  }

  # Insert the output of the shell command
  execute-keys '!<ret>'
}

You can also use a heredoc without interpolation or escapes:

lua <<'EOF'
  ...
EOF
1 Like

Would something like this work?

 execute-keys %{!lua -e "
        a = 'foo';
        io.write(a);
        "<ret>
}

@scr I added a tiny execute-key command to allow to do that.

execute-key ! %{
  lua -e '
    io.write("Hello, World!")
  '
}