martanne / vis

A vi-like editor based on Plan 9's structural regular expressions
Other
4.2k stars 258 forks source link

How to execute multiple commands in braces? #974

Closed honestSalami closed 2 years ago

honestSalami commented 2 years ago

I'm following rob pike's sam tutorial, and I ran into this sre:

,x/Emacs|vi/{
              g/Emacs/ c/vi/
              g/vi/ c/Emacs/
}

I'm trying to do it in vis like this: ,x/Emacs|vi/ {g/Emacs/ c/vi} {g/vi/ c/Emacs/}, but it returns 'unknown command'. Am I doing something wrong? Or is this not implemented in vis?

My version of vis is: vis v0.7-29-g1a958f2 +curses +lua +tre

honestSalami commented 2 years ago

I've tried :,x/(Emacs|vi)/ { g/Emacs/ c/vi ^M g/vi/ c/Emacs/ } too, as suggested by https://github.com/martanne/vis/wiki/Differences-from-Sam#limited-command-prompt-support-for-multi-line-commands, but it still returns 'unknown command'

acidrums4 commented 2 years ago

Just tried :x/(Emacs|vi)/ { g/Emacs/ c/vi g/vi/ c/Emacs/ } and it worked

honestSalami commented 2 years ago

hm, I tried it just as you typed it and it did not work for me. Could you publish your vis version and OS please?

acidrums4 commented 2 years ago

vis 0.7, Gentoo Linux

I suspect you are not typing the whole command but copy-paste'ing it. When I did it like that, it showed me that 'unknown command' message, but when typing it, it works

honestSalami commented 2 years ago

I finally got it to work. It seems that skipping the closing backlash was the problem: ,x/Emacs|vi/ { g/Emacs/ c/vi g/vi/ c/Emacs } vs ,x/Emacs|vi/ { g/Emacs/ c/vi/ g/vi/ c/Emacs/ }

Thank's for all the help! It was nice to have someone else worry about this : )