2

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.

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.