From 6f0b433fdf6386420e218c4ca4e9e5408e373423 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Tue, 30 Aug 2022 14:57:52 +0200 Subject: [PATCH] vim:keys: Add `dd` to clear line I sometimes have the situation that I want to create empty lines but they contain either whitespace from keeping the indentation and/or the comment string (`o` on a comment line). My current workflow is to either delete it and recreate it properly (e.g. from the 'other side' i.e. a non-comment line) or clear it with `cc`. Both ways are a bit awkward. Add a mapping that clears a line but stays in normal mode. Also remove the `d` mapping that deletes and puts the content into the system clipboard as I rarely use this one. --- .config/vim/vimrc.d/40-keys.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.config/vim/vimrc.d/40-keys.vim b/.config/vim/vimrc.d/40-keys.vim index 7fe2dc4..63815de 100644 --- a/.config/vim/vimrc.d/40-keys.vim +++ b/.config/vim/vimrc.d/40-keys.vim @@ -28,7 +28,6 @@ endif if (has('clipboard')) map y "+y map Y "+Y - map d "+d map p "+p map P "+P endif @@ -149,6 +148,9 @@ endif " Y should behave like D & C does nnoremap Y y$ +" Clear line (`cc` but stay in normal mode) +nmap dd ^D + " Move lines up and down while correcting the indentation " https://vim.fandom.com/wiki/Moving_lines_up_or_down " (Use arrows, as Alt-{j,k} is used by my terminal for scrollback)