Vim and the x11 clipboard

We can access the clipboard of x11 (the graphical system over which most desktop environments run, such as Gnome and KDE) to share text between Vim and other graphical applications.

x11 have two different global areas where it stores content to be shared between applications, one is known as the "cut-buffer", this is the location where the text that we copy or cut is stored, this is what most people associate with system clipboard. And the other is known as "selection", in x11, whenever we select something with our mouse, we can paste this selection in the location of the mouse cursor by pressing the middle button. Vim can access the content of both storages, get the text from this global storages, or put text on them.

Configure the syntax highlighting in Vim

When we enable syntax highlighting (by using :syntax enable), Vim will take into consideration the extension of the file to determine the appropriate syntax highlighting rules, and if this fails it will search the contents of the file for specific patterns in order to determine the file type. But if we are working in a temporary file that we don't intend to save, or if we opened, e.g., a file with HTML extension but we find that it contains PHP code in it, we can change the rules of the syntax highlighting.