everyone wants to know the opposite direction, how to exit line-editing "ex mode" and return to visual mode in vi, so it is tough to find information for this direction.
the correct answer is "Q", but vim 8.2 (package vim-runtime) in Ubuntu 22.04 has remapped Q to something completely unrelated ("formatting") so Q is inaccessible. (because everyone who hates line-editing also wants to configure vi never to accidentally enter "ex mode"). unlike emacs using M-x, there is no way to call a function by its long name if you just want to use it once. to make Q exit visual mode for the rest of the session: ":unmap Q". but of course that changes state, so you are not returning exactly to the same "ex" state that you started with: what if you then want to enter a visual mode with Q again having its remapped "formatting" behavior? I do not know of a way to restore Q to whatever it was before (without knowing what it was before) (unlike emacs, there is no local-set-key, local-unset-key). this is a mess.
to start "ex" (or "vi") with Q being available again: "ex -u NONE". or maybe "ex -u NONE -N". but "-u NONE" disables all initialization files, not just the Q remapping. (-u NONE also makes vim behave more like original vi, a large set of differences in behavior. -N modifies -u NONE to keep vim behaving like vim, which is good if you are used to vim not vi.) I could not find any way to disable just the Q remapping from the command line. this is a mess.
(if you want Q permanently available, you can create a user initialization file to override the system initialization file.)
the almost correct answer, even with "Q" remapped and inaccessible, is "gQ". but "Q" and "gQ" are subtly different (in a way I do not understand). when vim is invoked as "ex", it starts in "Q" mode, not "gQ" (according :h Q), and, as described above, there is no easy way to go back to Q after entering visual the first time. this is a mess.
Q mode (but not gQ mode) has been removed from neovim (nvim). if invoked as "ex", neovim presumably starts in gQ mode, but this is not documented anywhere I could find.
No comments :
Post a Comment