aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Anders <greg@gpanders.com>2021-08-16 19:28:52 -0600
committerGitHub <noreply@github.com>2021-08-16 18:28:52 -0700
commit2cb8db34e3a275dec3dacb10fdc75640f4ec8174 (patch)
treed49331f40470d9084e6198439c08cac4d5478e74
parent3954537b9e243fb3df3672d47fe3d9529fa4e544 (diff)
downloadrneovim-2cb8db34e3a275dec3dacb10fdc75640f4ec8174.tar.gz
rneovim-2cb8db34e3a275dec3dacb10fdc75640f4ec8174.tar.bz2
rneovim-2cb8db34e3a275dec3dacb10fdc75640f4ec8174.zip
feat: defaults: set undo points in <C-U> and <C-W> (#15400)
-rw-r--r--runtime/doc/insert.txt6
-rw-r--r--runtime/doc/vim_diff.txt2
-rw-r--r--src/nvim/getchar.c8
-rw-r--r--src/nvim/normal.c6
-rw-r--r--src/nvim/testdir/setup.vim2
-rw-r--r--test/functional/helpers.lua2
6 files changed, 20 insertions, 6 deletions
diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt
index c8a4168ab2..bb00c77ca8 100644
--- a/runtime/doc/insert.txt
+++ b/runtime/doc/insert.txt
@@ -68,12 +68,18 @@ CTRL-A Insert previously inserted text.
CTRL-W Delete the word before the cursor (see |i_backspacing| about
joining lines). See the section "word motions",
|word-motions|, for the definition of a word.
+ *i_CTRL-W-default*
+ By default, sets a new undo point before deleting.
+ |default-mappings|
*i_CTRL-U*
CTRL-U Delete all entered characters before the cursor in the current
line. If there are no newly entered characters and
'backspace' is not empty, delete all characters before the
cursor in the current line.
See |i_backspacing| about joining lines.
+ *i_CTRL-U-default*
+ By default, sets a new undo point before deleting.
+ |default-mappings|
*i_CTRL-I* *i_<Tab>* *i_Tab*
<Tab> or CTRL-I Insert a tab. If the 'expandtab' option is on, the
equivalent number of spaces is inserted (use CTRL-V <Tab> to
diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt
index ecc3f52077..7e1bd3e087 100644
--- a/runtime/doc/vim_diff.txt
+++ b/runtime/doc/vim_diff.txt
@@ -78,6 +78,8 @@ Default Mappings: *default-mappings*
nnoremap Y y$
nnoremap <C-L> <Cmd>nohlsearch<Bar>diffupdate<CR><C-L>
+inoremap <C-U> <C-G>u<C-U>
+inoremap <C-W> <C-G>u<C-W>
==============================================================================
3. New Features *nvim-features*
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 63da6f7922..4bf1c90830 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -841,6 +841,14 @@ static void init_typebuf(void)
}
}
+void init_default_mappings(void)
+{
+ add_map((char_u *)"Y y$", NORMAL, true);
+ add_map((char_u *)"<C-L> <Cmd>nohlsearch<Bar>diffupdate<CR><C-L>", NORMAL, true);
+ add_map((char_u *)"<C-U> <C-G>u<C-U>", INSERT, true);
+ add_map((char_u *)"<C-W> <C-G>u<C-W>", INSERT, true);
+}
+
// Insert a string in position 'offset' in the typeahead buffer (for "@r"
// and ":normal" command, vgetorpeek() and check_termcode())
//
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index f3869e7e44..2a530db934 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -397,12 +397,6 @@ void init_normal_cmds(void)
nv_max_linear = i - 1;
}
-void init_default_mappings(void)
-{
- add_map((char_u *)"Y y$", NORMAL, true);
- add_map((char_u *)"<C-L> <Cmd>nohlsearch<Bar>diffupdate<CR><C-L>", NORMAL, true);
-}
-
/*
* Search for a command in the commands table.
* Returns -1 for invalid command.
diff --git a/src/nvim/testdir/setup.vim b/src/nvim/testdir/setup.vim
index 57ba57a3c8..58ce0f1a4c 100644
--- a/src/nvim/testdir/setup.vim
+++ b/src/nvim/testdir/setup.vim
@@ -27,6 +27,8 @@ set switchbuf=
" Unmap Nvim default mappings.
unmap Y
unmap <C-L>
+iunmap <C-U>
+iunmap <C-W>
" Prevent Nvim log from writing to stderr.
let $NVIM_LOG_FILE = exists($NVIM_LOG_FILE) ? $NVIM_LOG_FILE : 'Xnvim.log'
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index 21ae529b71..a1b464af13 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -44,6 +44,8 @@ module.nvim_argv = {
'--cmd', module.nvim_set,
'--cmd', 'unmap Y',
'--cmd', 'unmap <C-L>',
+ '--cmd', 'iunmap <C-U>',
+ '--cmd', 'iunmap <C-W>',
'--embed'}
-- Directory containing nvim.