aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2015-09-07 22:27:21 -0400
committerJustin M. Keyes <justinkz@gmail.com>2015-10-26 02:23:59 -0400
commit0f9dea2a0e344ded3bd4f8664acfed4fd3381c8e (patch)
tree6a01f4ec62b4ed0f5dd856987b62eefb38f377b4 /runtime
parent1ca5646bb52ec5c23b28f45bb7bc5d25cffad9b0 (diff)
downloadrneovim-0f9dea2a0e344ded3bd4f8664acfed4fd3381c8e.tar.gz
rneovim-0f9dea2a0e344ded3bd4f8664acfed4fd3381c8e.tar.bz2
rneovim-0f9dea2a0e344ded3bd4f8664acfed4fd3381c8e.zip
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
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/insert.txt26
1 files changed, 26 insertions, 0 deletions
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 <Left> <C-G>U<Left>
+ inoremap <Right> <C-G>U<Right>
+ inoremap <expr> <Home> col('.') == match(getline('.'), '\S') + 1 ?
+ \ repeat('<C-G>U<Left>', col('.') - 1) :
+ \ (col('.') < match(getline('.'), '\S') ?
+ \ repeat('<C-G>U<Right>', match(getline('.'), '\S') + 0) :
+ \ repeat('<C-G>U<Left>', col('.') - 1 - match(getline('.'), '\S')))
+ inoremap <expr> <End> repeat('<C-G>U<Right>', col('$') - col('.'))
+ inoremap ( ()<C-G>U<Left>
+
+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: >