简体   繁体   中英

Emacs function: [pre] marked region [post]

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 ".

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.

在乳胶模式下, Cc Co做到这一点。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM