aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-06-04 02:06:32 +0200
committerJustin M. Keyes <justinkz@gmail.com>2018-06-17 14:50:53 +0200
commit9c2099d5850a6a434f7269913d316d57da1362e2 (patch)
tree01dd9cc3e83a177d092995226a4541dfe2cb08e4
parent3cc350696576f26fe1e978ef78125a1a6c7410ab (diff)
downloadrneovim-9c2099d5850a6a434f7269913d316d57da1362e2.tar.gz
rneovim-9c2099d5850a6a434f7269913d316d57da1362e2.tar.bz2
rneovim-9c2099d5850a6a434f7269913d316d57da1362e2.zip
Ex mode: use getexline() instead of getexmodeline()
This changes Ex mode (Q, -e) to work like Vim's "improved Ex mode" (gQ, -E). That brings some small behavior differences, but should not impact most Ex scripts (unless, for example, they depend on mappings being disabled--but that can be solved for -e by skipping user config). Before this change: * the screen test hangs. After this change: * Q acts like gQ. * -e/-es differs from -E/-Es only in its treatment of stdin. This moves towards potentially removing getexmodeline(). (HINT: That does NOT mean "removing Ex mode", it means removing the Vi-compatible Ex mode, which differs from Vim's "improved Ex mode" only in some minor details (e.g. mappings are disabled).) ref #1089 :-)~
-rw-r--r--man/nvim.12
-rw-r--r--runtime/doc/intro.txt21
-rw-r--r--runtime/doc/starting.txt14
-rw-r--r--runtime/doc/vim_diff.txt7
-rw-r--r--src/nvim/ex_docmd.c18
-rw-r--r--src/nvim/main.c6
-rw-r--r--test/functional/core/startup_spec.lua12
7 files changed, 39 insertions, 41 deletions
diff --git a/man/nvim.1 b/man/nvim.1
index 28b699a07b..0040af2865 100644
--- a/man/nvim.1
+++ b/man/nvim.1
@@ -78,7 +78,7 @@ Ex mode. Reads stdin as Ex commands.
See
.Ic ":help Ex-mode" .
.It Fl E
-Ex mode, improved. Reads stdin as text.
+Ex mode. Reads stdin as text.
See
.Ic :help gQ .
.It Fl es
diff --git a/runtime/doc/intro.txt b/runtime/doc/intro.txt
index e7fb632de8..5c63d9e5e2 100644
--- a/runtime/doc/intro.txt
+++ b/runtime/doc/intro.txt
@@ -642,25 +642,12 @@ The command CTRL-\ CTRL-G or <C-\><C-G> can be used to go to Insert mode when
make sure Vim is in the mode indicated by 'insertmode', without knowing in
what mode Vim currently is.
- *Q* *mode-Ex* *Ex-mode* *Ex* *EX* *E501*
-Q Switch to "Ex" mode. This is a bit like typing ":"
- commands one after another, except:
+ *gQ* *Q* *mode-Ex* *Ex-mode* *Ex* *EX* *E501*
+Q or gQ Switch to Ex mode. This is like typing ":" commands
+ one after another, except:
- You don't have to keep pressing ":".
- The screen doesn't get updated after each command.
- - There is no normal command-line editing.
- - Mappings and abbreviations are not used.
- In fact, you are editing the lines with the "standard"
- line-input editing commands (<Del> or <BS> to erase,
- CTRL-U to kill the whole line).
- Vim will enter this mode by default if it's invoked as
- "ex" on the command-line.
- Use the ":vi" command |:visual| to exit "Ex" mode.
-
- *gQ*
-gQ Switch to "Ex" mode like with "Q", but really behave
- like typing ":" commands after another. All command
- line editing, completion etc. is available.
- Use the ":vi" command |:visual| to exit "Ex" mode.
+ Use the ":vi" command |:visual| to exit this mode.
==============================================================================
7. The window contents *window-contents*
diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt
index e89d72bce3..ad1077bcab 100644
--- a/runtime/doc/starting.txt
+++ b/runtime/doc/starting.txt
@@ -185,11 +185,12 @@ argument.
delete(), rename(), mkdir(), writefile(), libcall(),
jobstart(), etc.
- *-e*
--e Start Vim in Ex mode |Q|.
+-e *-e* *-E*
+-E Start Nvim in Ex mode |gQ|.
- *-E*
--E Start Vim in improved Ex mode |gQ|.
+ If stdin is not a TTY:
+ -e reads stdin as Ex commands.
+ -E reads stdin as text (into buffer 1).
*-es* *-Es*
-es *-s-ex* *silent-mode*
@@ -207,6 +208,11 @@ argument.
<
User |init.vim| is skipped (unless given with |-u|).
|$TERM| is not used.
+
+ If stdin is not a TTY:
+ -es reads stdin as Ex commands.
+ -Es reads stdin as text (into buffer 1).
+
Example: >
printf "put ='foo'\n%%print\n" | nvim -es
<
diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt
index 5394414947..0035e15be1 100644
--- a/runtime/doc/vim_diff.txt
+++ b/runtime/doc/vim_diff.txt
@@ -315,10 +315,15 @@ Macro/|recording| behavior
macros and 'keymap' at the same time. This also means you can use |:imap| on
the results of keys from 'keymap'.
+Normal commands:
+ |Q| is the same as |gQ|
+
Options:
'ttimeout', 'ttimeoutlen' behavior was simplified
Startup:
+ |-e| and |-es| invoke the same "improved Ex mode" as -E and -Es.
+ |-E| and |-Es| reads stdin as text (into buffer 1).
|-s| reads Normal commands from stdin if the script name is "-".
Reading text (instead of commands) from stdin |--|:
- works by default: "-" file is optional
@@ -465,4 +470,4 @@ TUI:
always uses 7-bit control sequences.
==============================================================================
- vim:tw=78:ts=8:noet:ft=help:norl:
+ vim:tw=78:ts=8:sw=2:noet:ft=help:norl:
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 9590a3715e..2f41080a41 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -188,15 +188,8 @@ static void restore_dbg_stuff(struct dbg_stuff *dsp)
current_exception = dsp->current_exception;
}
-
-/*
- * do_exmode(): Repeatedly get commands for the "Ex" mode, until the ":vi"
- * command is given.
- */
-void
-do_exmode (
- int improved /* TRUE for "improved Ex" mode */
-)
+/// Repeatedly get commands for Ex mode, until the ":vi" command is given.
+void do_exmode(int improved)
{
int save_msg_scroll;
int prev_msg_row;
@@ -232,11 +225,8 @@ do_exmode (
changedtick = curbuf->b_changedtick;
prev_msg_row = msg_row;
prev_line = curwin->w_cursor.lnum;
- if (improved) {
- cmdline_row = msg_row;
- do_cmdline(NULL, getexline, NULL, 0);
- } else
- do_cmdline(NULL, getexmodeline, NULL, DOCMD_NOWAIT);
+ cmdline_row = msg_row;
+ do_cmdline(NULL, getexline, NULL, 0);
lines_left = Rows - 1;
if ((prev_line != curwin->w_cursor.lnum
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 8d98f9e915..7296d9a7de 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -872,7 +872,7 @@ static void command_line_scan(mparm_T *parmp)
exmode_active = EXMODE_NORMAL;
break;
}
- case 'E': { // "-E" Improved Ex mode
+ case 'E': { // "-E" Ex mode
exmode_active = EXMODE_VIM;
break;
}
@@ -1896,8 +1896,8 @@ static void usage(void)
mch_msg("\n");
mch_msg(_(" -b Binary mode\n"));
mch_msg(_(" -d Diff mode\n"));
- mch_msg(_(" -e, -E Ex mode, Improved Ex mode\n"));
- mch_msg(_(" -es Silent (batch) mode\n"));
+ mch_msg(_(" -e, -E Ex mode\n"));
+ mch_msg(_(" -es, -Es Silent (batch) mode\n"));
mch_msg(_(" -h, --help Print this help message\n"));
mch_msg(_(" -i <shada> Use this shada file\n"));
mch_msg(_(" -m Modifications (writing files) not allowed\n"));
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua
index f323056179..c20ac668c4 100644
--- a/test/functional/core/startup_spec.lua
+++ b/test/functional/core/startup_spec.lua
@@ -123,9 +123,19 @@ describe('startup', function()
end)
it('-e/-E interactive #7679', function()
- clear('-E')
+ clear('-e')
local screen = Screen.new(25, 3)
screen:attach()
+ feed("put ='from -e'<CR>")
+ screen:expect([[
+ :put ='from -e' |
+ from -e |
+ :^ |
+ ]])
+
+ clear('-E')
+ screen = Screen.new(25, 3)
+ screen:attach()
feed("put ='from -E'<CR>")
screen:expect([[
:put ='from -E' |