Function: web-mode-surround
web-mode-surround is an interactive and natively compiled function
defined in web-mode.el.
Signature
(web-mode-surround)
Documentation
Surround each line of the current REGION with a start/end tag.
Key Bindings
This command is not in any keymaps.
Source Code
;; Defined in /nix/store/2qgnz1rp30nzfz6w0apx4kdm14if1bbs-emacs-packages-deps/share/emacs/site-lisp/elpa/web-mode-20260831.219/web-mode.el
(defun web-mode-surround ()
"Surround each line of the current REGION with a start/end tag."
(interactive)
(when mark-active
(let (beg end line-beg line-end tag tag-start tag-end)
(save-excursion
(combine-after-change-calls
(setq tag (web-mode-element-complete)
tag-start (concat "<" tag ">")
tag-end (concat "</" tag ">")
beg (region-beginning)
end (region-end)
line-beg (web-mode-line-number beg)
line-end (web-mode-line-number end))
(goto-char end)
(unless (bolp)
(insert tag-end)
(back-to-indentation)
(when (> beg (point))
(goto-char beg))
(insert tag-start))
(while (> line-end line-beg)
(forward-line -1)
(setq line-end (1- line-end))
(unless (looking-at-p "[[:space:]]*$")
(end-of-line)
(insert tag-end)
(back-to-indentation)
(when (> beg (point))
(goto-char beg))
(insert tag-start))
) ;while
(deactivate-mark)
) ;combine-after-change-calls
) ;save-excursion
)))