More Vim tips

- 1 min

I will continue my previous post with another few Vim tips I recently found in my quest to improve my Vim experience!

1) For those of you annoyed by the auto-comment feature of Vim (the feature that automatically inserts a comment leader in front of a line after your previous line was also commented), just enter this:

:set fo-=r

2) If you are like me and like to use Ctrl+E and Ctrl+A in your command line and want to also use this in Vim, here is a simple way to map end of line and beginning of line to Ctrl+E and Ctrl+A in Vim:

" map CTRL-E to end-of-line (insert mode)
imap <C-e> <esc>$i<right>
" map CTRL-A to beginning-of-line (insert mode)
imap <C-a> <esc>0i
" map CTRL-E to end-of-line (normal mode)
nmap <C-e> $
" map CTRL-A to beginning-of-line (normal mode)
nmap <C-a> 0

3) This is for the lazy ones or the ones that just can not get adjusted to Vim’s shortcuts, here is a trick to map Ctrl+C to copy to clipboard, Ctrl+V to paste and Ctrl+X to cut:

" map CTRL-C to copy (visual mode)
vmap <C-c> y
" map CTRL-X to cut (visual mode)
vmap <C-x> x
" map CTRL-V to paste (insert mode)
imap <C-v> <esc>P

Add them to your .vimrc and that’s it!

rss facebook twitter github youtube mail spotify instagram linkedin google pinterest medium tumblr soundcloud blog