Improve the documented editorcmd for Vim

Problems with the original:
- Addressing the column with "l" assumes that "G" positions the cursor on the first column. But the default behavior already skips leading indent (so is wrong when there's leading whitespace), and with ":set nostartofline", the current column actually is kept (which completely and randomly messes up the column addressing).
- ":normal" without ! is affected by mappings; users may have tweaked the "G" and "l" (or in the worst case completely changed the behavior, e.g. for use with a different keyboard layout).

This change makes the mapping immune to mappings (with ":normal!") and uses the "|" command (which uses virtual column addressing independent of the current column or "G" behavior) instead of "c".
Additionally, "zv" makes the current line visible should it be obscured by folding. (Vim may detect a filetype and automatically enable folding.)
Instead of -c <cmd>, the shorter +<cmd> form is used. This is just a cosmetic change. Using just a single argument and avoiding any whitespace within it may prevent command-line argument parsing issues.
This commit is contained in:
Ingo Karkat 2020-03-17 20:18:54 +01:00
parent 2f02f3e446
commit b755391aed

View file

@ -307,7 +307,7 @@ export function removeTridactylEditorClass(selector: string) {
*
* The editorcmd needs to accept a filename, stay in the foreground while it's edited, save the file and exit. By default the filename is added to the end of editorcmd, if you require control over the position of that argument, the first occurrence of %f in editorcmd is replaced with the filename. %l, if it exists, is replaced with the line number of the cursor and %c with the column number. For example:
* ```
* set editorcmd terminator -u -e "vim %f -c 'normal %lG%cl'"
* set editorcmd terminator -u -e "vim %f '+normal!%lGzv%c|'"
* ```
*
* You're probably better off using the default insert mode bind of `<C-i>` (Ctrl-i) to access this.