Question

Selecting region, how to get a (pre)defined part before and after region?

Let's say for instance, working with LaTeX, we want \begin{frame}{} before the region and \end{frame} after region, how to get this done with Emacs by one function?

    [pre-part]"Has to be around this"[post-part] 

I would encourage use of yasnippet. Also, maybe "autopare" can give a hint, since somehow it smartly can put quote signs around the marked region when pressing ".

Was it helpful?

Solution

You can use yasnippet. Here is an example for an html tag snippet that can wrap or not.

# -*- mode: snippet -*-
# name: Wrap open close tags
# binding: C-c C-t
# expand-env: ((yas-wrap-around-region t))
# --
<$1>$0</${1:$(car (split-string text))}>

This works with the latest github version of yasnippet.

OTHER TIPS

In latex-mode, C-c C-o does just that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top