vim

Useful configurations that can be put in .vimrc

Syntax#

  • set mouse=a
  • set wrap
  • nmap j gj
  • nmap k gk

Move up/down displayed lines when wrapping

Usually, J and K move up and down file lines. But when you have wrapping on, you may want them to move up and down the displayed lines instead.

set wrap " if you haven't already set it
nmap j gj
nmap k gk

Enable Mouse Interaction

set mouse=a

This will enable mouse interaction in the vim editor. The mouse can

  • change the current cursor’s position
  • select text

Configure the default register to be used as system clipboard

set clipboard=unnamed

This makes it possible to copy/paste between Vim and the system clipboard without specifying any special register.

yy yanks the current line into the system clipboard

p pastes the content of the system clipboard into Vim

This only works if your Vim installation has clipboard support. Run the following command in the terminal to check if the clipboard option is available: vim --version | grep clipboard


This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow