Adding a Keyboard Shortcut to VIM

The below example will show you how to use Ctrl + k as a keyboard shortcut to execute the following key sequence when you are in insert mode : <esc>:wq<Enter>

Example

  1. open ~/.vimrc file
  2. go to the bottom of the file
  3. add the following line
    inoremap <C-k> <esc>:wq<Enter>
  4. save and close file
  5. exit and restart terminal

Leave a comment

Your email address will not be published. Required fields are marked *