1. Frank Fischer
  2. evil
  3. Issues
Issue #251 resolved

:normal in Ex state

mheathr
created an issue

It would be very nice if Evil supported VIM's :{range}normal command in Ex state. Doing so allows creating much less fragile macros as if the created macro fails to do an operation it does not quit, it merely continues to the next line in the range given. The command is described below in VIM's help (:h normal).

:norm[al][!] {commands} :norm :normal Execute Normal mode commands {commands}. This makes it possible to execute Normal mode commands typed on the command-line. {commands} are executed like they are typed. For undo all commands are undone together. Execution stops when an error is encountered. If the [!] is given, mappings will not be used. {commands} should be a complete command. If {commands} does not finish a command, the last one will be aborted as if <Esc> or <C-C> was typed. The display isn't updated while ":normal" is busy. This implies that an insert command must be completed (to start Insert mode, see |:startinsert|). A ":" command must be completed as well. And you can't use "Q" or "gQ" to start Ex mode. {commands} cannot start with a space. Put a count of 1 (one) before it, "1 " is one space. The 'insertmode' option is ignored for {commands}. This command cannot be followed by another command, since any '|' is considered part of the command. This command can be used recursively, but the depth is limited by 'maxmapdepth'. When this command is called from a non-remappable mapping |:noremap|, the argument can be mapped anyway. An alternative is to use |:execute|, which uses an expression as argument. This allows the use of printable characters to represent special characters. Example: > :exe "normal \<c-w>\<c-w>" < {not in Vi, of course} {not available when the |+ex_extra| feature was disabled at compile time}

:{range}norm[al][!] {commands} :normal-range Execute Normal mode commands {commands} for each line in the {range}. Before executing the {commands}, the cursor is positioned in the first column of the range, for each line. Otherwise it's the same as the ":normal" command without a range. {not in Vi} {not available when |+ex_extra| feature was disabled at compile time}

Comments (10)

  1. Frank Fischer repo owner

    Implement :normal command.

    This implementation is not completely equivalent to Vim's. That's because it relies on Emacs to do the interpretation of the normal state command using execute-kbd-macro.

    The bang argument is not supported.

    This addresses issue #251.

    → <<cset a4b3c1aae3b3>>

  2. mheathr reporter

    It appears to work mostly. I was testing the function against

    1. one
    2. two
    3. three
    4. four
    

    aiming to turn it into

    1) One
    2) Two
    3) Three
    4) Four
    

    and that works if I use ":'<,'>normal 0f.r)wgUl"

    Thanks

  3. Frank Fischer repo owner

    Implement :normal command.

    This implementation is not completely equivalent to Vim's. That's because it relies on Emacs to do the interpretation of the normal state command using execute-kbd-macro.

    The bang argument is not supported.

    This addresses issue #251.

    → <<cset a4b3c1aae3b3>>

  4. Log in to comment