sid_com
sid_com

Reputation: 25117

How do I escape the %-character in a vimrc-file?

How could I escape the % in this example?

func! my_func()
  exec "!printf '=%.0s' {1..100}"
endfunc

Upvotes: 0

Views: 472

Answers (1)

ZyX
ZyX

Reputation: 53644

Use shellescape for any string that is a single argument (not a list of space-separated arguments) and may contains special characters (including space itself):

let suspicious_string='=%.0s'
exec "!printf ".shellescape(suspicious_string, 1)." {1..100}"

Upvotes: 3

Related Questions