ESC :r <path-and-filename>
For example, if we need to read the contents of a file called
if located in
$HOME/snippets, we will use the following key sequences in
ESC :r $HOME/snippets/if
The contents of this file is read into the current document below the current cursor position. In this way, we can make the code snippets as complex as we need and maintain the correct indentations to aide readability and consistency.
So, we will make it our duty to always create a snippets directory in our home directory:
$ mkdir -m 700 $HOME/snippets
It is not required to share the directory, so it is good practice to set the mode to
700 or private to the user when it is being created.