Emacs Auto-Completion has many plugins, Yasnippet is a code fragment completion tool, which can be used to complement the large section of the common
The code snippet is similar to the TextMate on your Mac.
Recommended installation method is Package-install
M-x list-packages Find Yasnippet installation can
Then add the following in the configuration file:
(Require ' Yasnippet) (Yas/global-mode 1)
The installation is complete, and after that, just put your own definition drop into the corresponding mode file under the. emacs.d/snippet/
Just a pinch, like I want to use my Usaco template in C++-mode:
I will write the following Usaco template:
# Name:usaco ... { ... } # key:usaco#--/*id:twd30651prog:${1:programname}lang:c++*/#include <iostream> #include <fstream>using namespace Std;int Main (int Argc,char *argv[]) { freopen ("${1:$ (yas-substr yas-text" [^:]* ")}.in", "R", stdin); Freopen ("${1:$ (yas-substr yas-text" [^:]* ")}.out", "w", stdout); $ return 0;}
Come to a demo effect ~ ~
Using Yasnippet template Completion to customize the Usaco template as an example