Using template in Vim

Revision en1, by Qualified, 2020-06-09 02:59:23

Have you ever wondered how to make your very own template? In all of the other IDEs like VSCode, Sublime have templates in which you type in a set string of characters like "cpp" and then your template appears. This is actually very simple and only requires one line of code in your .vimrc

nnoremap cpp :-1read ABC<CR>

where "ABC" is the location of that file containing your template. The "cpp" after "nnoremap" actually determines what you should type into vim in order for your template to appear. For example:

nnoremap cpp :-1read C:\Users\Qualified\Desktop\Template\template.cpp<CR>

where Qualified is the name of my computer and Template is the folder which contains the template.cpp file which holds my template.

Hope that this helped many people!

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Qualified 2020-06-09 02:59:23 824 Initial revision (published)