Artificial intelligent assistant

How to use vim command-mode indention in ex colon-mode? I am trying to script some file changes using `ex` per this answer. The issue that I'm running into is that `ex` seems to assume that every command is preceded by a colon, so while I can do something like: /^foo() a test insertion . w! q I can't do: /^foo() >iB O if (bar()) . w! q because it chokes on the second and third lines, as nearly as I can tell because `:>iB` and `:O` both return errors in `vim`. What am I doing wrong? How can I indent the current braces block and/or insert above the current line within `ex`?

> `ex` seems to assume that every command is preceded by a colon […]

Actually, _you_ are assuming that `vi` commands and `ex` commands are the same thing. The character sequences that you type in full-screen mode to `vi` _are not_ the command language of `ex`.

To insert above instead of append below, use `insert` instead of `append`.

To shift the current line left and right, use `>` and `<` on their own. To shift a block, prefix them with a line range that specifies the block.

# Further reading

* Dale Dougherty and Tim O'Reilly (1987). "Advanced Editing". _Unix Text Processing_. Hayden Books.
* "Utilities: ex". _Shell Command Language_. Single UNIX Specification. Issue 7. IEEE 1003.1. 2016. The Open Group.
* "EX COMMANDS". _`ex`_. _FreeBSD General Commands Manual_. 2013-11-02.
* `:help cmdline-lines` (NeoVIM)
* `:help cmdline-lines` (VIM)
* `:exusage` (nvi)

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 7ffce60f79aaaf3946b277c05898b1b3