Emacs: enter commands like in gedit

in gedit, you can define so-called "fragments" for easier input.

For example, there is a fragment while. This means: If you type while ->( ->means tab). And gedit will automatically convert it to the following (including proper indentation):

while (condition){

}

In vim (combined with the latex package), I saw the following: if you type (, vim only inserts a (. If you type a (second time, vim will automatically convert it to \left( \right).

I found abbrev-mode, but this mode does not position the cursor properly (i.e. between parentheses or inside a while loop).

I managed to create custom emacs keyboard shortcuts / macros that do the same thing (without pressing the tab keys), so I know that this is possible.

However, is there already a package where you can define such "fragments" without much effort? Or are there even serious reasons not to use such things?

+5
source share
3 answers

See yasnippet . It provides snippets for most major languages, and it's easy to add or change old ones.

+8
source

, yasnippet - , , . , , - LaTeX auctex. , . / LaTeX C-c C-e auctex. Etc:)

+3

Do not forget the abbrev mode.

+1
source

All Articles