Is there an easy way to wrap a buffer in emacs with text of my choice? For e.g if my selected buffer is like this,
This is the first line of a verse with ।
And here comes the second line ॥ 1.2 ॥
I want to add custom markers to the top and bottom of the verse like this:
\begin{myverse}
This is the first line of a verse with ।
And here comes the second line ॥ 1.2 ॥
\end{myverse}
I'm running evil mode in emacs 27.1 on OSX. Right now I copy each of the tags \begin{myverse}
and \end{myverse}
into named vim buffers, move the cursor to the right location and paste the desired text. I'm hoping there's a faster way of accomplishing this and am open to any solutions in emacs or vim.
EDIT 1: I believe there's an emacs way to move to the beginning of a buffer, add a newline insert some text, again move to the end of that buffer, add a newline and insert text.
M-x eval-expression RET (let ((beg-text "\\begin{myverse}") (end-text "\\end{myverse}")) (save-excursion (goto-char (point-min)) (insert beg-text "\n") (goto-char (point-max)) (insert "\n" end-text))) RET
NOTE: There are built-in solutions for surrounding text with LaTeX code, as well as using the popular AUCTex library. There are also skeleton libraries designed for buffer inserts. – lawlist Jan 2 at 0:24