From 0f9dea2a0e344ded3bd4f8664acfed4fd3381c8e Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 7 Sep 2015 22:27:21 -0400 Subject: vim-patch:7.4.849 Problem: Moving the cursor in Insert mode starts new undo sequence. Solution: Add CTRL-G U to keep the undo sequence for the following cursor movement command. (Christian Brabandt) https://github.com/vim/vim/commit/8b5f65a527c353b9942e362e719687c3a7592309 Closes #3492 --- runtime/doc/insert.txt | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt index 2572aa1e91..a48ad0185d 100644 --- a/runtime/doc/insert.txt +++ b/runtime/doc/insert.txt @@ -363,6 +363,9 @@ CTRL-O execute one command, return to Insert mode *i_CTRL-O* CTRL-\ CTRL-O like CTRL-O but don't move the cursor *i_CTRL-\_CTRL-O* CTRL-L when 'insertmode' is set: go to Normal mode *i_CTRL-L* CTRL-G u break undo sequence, start new change *i_CTRL-G_u* +CTRL-G U don't break undo with next left/right cursor *i_CTRL-G_U* + movement (but only if the cursor stays + within same the line) ----------------------------------------------------------------------- Note: If the cursor keys take you out of Insert mode, check the 'noesckeys' @@ -402,6 +405,29 @@ that, with CTRL-O u. Another example: > This breaks undo at each line break. It also expands abbreviations before this. +An example for using CTRL-G U: > + + inoremap U + inoremap U + inoremap col('.') == match(getline('.'), '\S') + 1 ? + \ repeat('U', col('.') - 1) : + \ (col('.') < match(getline('.'), '\S') ? + \ repeat('U', match(getline('.'), '\S') + 0) : + \ repeat('U', col('.') - 1 - match(getline('.'), '\S'))) + inoremap repeat('U', col('$') - col('.')) + inoremap ( ()U + +This makes it possible to use the cursor keys in Insert mode, without breaking +the undo sequence and therefore using |.| (redo) will work as expected. +Also entering a text like (with the "(" mapping from above): > + + Lorem ipsum (dolor + +will be repeatable by the |.|to the expected + + Lorem ipsum (dolor) + + Using CTRL-O splits undo: the text typed before and after it is undone separately. If you want to avoid this (e.g., in a mapping) you might be able to use CTRL-R = |i_CTRL-R|. E.g., to call a function: > -- cgit