Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
I want to save selected text in vim. I use command :'<,'>w! ~/save.txt.
How to write a short command instead of it, or mapping it to key mappings.
Here you go:
vnoremap <Leader>s :w! ~/save.txt <CR>
Just paste this into your init.vim. This assumes you have the text highlighted and are currently in visual mode. Just hit Leader+s and it will save the selection for you.
Required, but never shown