user2242865
user2242865

Reputation: 567

edit a Vim macro with a range operation that refers to a tag

I created a macro with a range (http://vim.wikia.com/wiki/Ranges) operation like:

:.,'bs/ .*$\n/ /ge^M

I then wanted to edit it, which I would normally do using let (http://vim.wikia.com/wiki/Macros#Editing_a_macro):

:let @b=':.,'bs/ .*$\n/ /ge^Mdd'

But for these examples, the ' in the macro definition causes the edit to fail. How to resolve this? Either an alternate range syntax or a way to escape the quote when defining.

I know I can re-record the macro, but the actual version is much longer than this!

Upvotes: 2

Views: 60

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172530

  • Single quotes need to be doubled inside such string: :let @b=':.,''bs/ .*$\n/ /ge^Mdd'
  • You could use double quotes, but then also double backslashes (if there are any) :let @b=":.,'bs/ .*$\\n/ /ge^Mdd"
  • Instead of :let, you could :put b into a scratch buffer, edit, then "by$ into the register again.

Upvotes: 3

Related Questions