Sometimes I want to clear a line in vim
rather than delete it.
Before:
foo
bar
lineToClear
baz
After
foo
bar
baz
Of the vim
commands I know, the closest I can get to this is D
(upper case d), but usually this requires me to type 0
first to go to the beginning of the line.
I know, I'm lazy.
Does there exist a command that just clears the entire line, not just the characters after the cursor?
Maybe some sort of Containment-esque type of direct brain interface?
Clear Command Prompt with CLS Command Enter multiple standard commands into the blank cmd screen. Next type CLS and press Enter button. This will clear all the previously entered commands from the CMD screen in Windows.
A common way to do that is to use the `clear` command, or its keyboard shortcut CTRL+L.
Clear Terminal via Ctrl+L / Ctrl+Shift+K Shortcut Keyboard shortcuts also work for clearing the terminal, depending on the terminal emulator. An alternative in some terminal emulators is Ctrl + Shift + K .
You can use S
. It clears the line, then puts you into insert mode. If you don't want to do insert mode, 0D
will be the quickest command set.
As glts mentioned, you can create a custom mapping by running one of the following commands. The first argument (S/D) can be changed to whatever you'd like.
:nnoremap S S<Esc>
or
:nnoremap D 0D
Reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With