Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open selection in different major mode.

Tags:

emacs

Is it possible to select some parts of a text and open it in a different buffer with a different mode?

Fore example, if I often work in ESS mode (syntax highlighting for R),

astring <- '<form>
<input type="checkbox" id="foo", value="bar">
</form>'

if the text within the single quotes is selected, I would like to edit it in a new buffer HTML mode (similar to org-src-lang-modes in orgmode).

like image 350
johannes Avatar asked Mar 27 '26 13:03

johannes


1 Answers

What you're describing is called an 'indirect buffer'. You create one by calling M-x clone-indirect-buffer. This creates a second copy of the buffer you're editing. Any changes made in one buffer are mirrored in the other. However, both buffers can have different major modes active, so one can be in ESS mode, and the other in HTML (or whatever you like).

See the manual for details.

like image 110
Tyler Avatar answered Mar 29 '26 09:03

Tyler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!