I want to bind Ctrl-w with :q
command in vim That is to say, I want to use Ctrl-w to close the current window of vim,
So I add this to my ~/.vimrc
:
nmap <C-W> :q<cr>
When I use this to close a window that has something unsaved,this command cannot work.
So I want to make it works in a smart way: When the content is saved, just close the window. When the content remains unsaved, ask me whether to close the window directly like this command
:0,$s/a/b/gc
I don't know if this is clear enough for you, but thanks in advance.
There's the :confirm
command for that. Just put it in front of :quit
:
:nmap <C-W> :confirm q<cr>