Tre*_*son 11
这是一个实现upcase-rectangle,它将大小写改为全部大写.只需替换你想要的upcasewith downcase或者capitalize任何自定义大小写转换:
(defun upcase-rectangle (b e)
"change chars in rectangle to uppercase"
(interactive "r")
(apply-on-rectangle 'upcase-rectangle-line b e))
(defun upcase-rectangle-line (startcol endcol)
(when (= (move-to-column startcol) startcol)
(upcase-region (point)
(progn (move-to-column endcol 'coerce)
(point)))))
Run Code Online (Sandbox Code Playgroud)
使用cua-mode矩形选择支持很容易:
(setq cua-enable-cua-keys nil) ; enable only CUA's rectangle selections
(cua-mode t)
Run Code Online (Sandbox Code Playgroud)
然后,您可以通过按下C-RET并移动光标来选择矩形.要更新该区域,只需使用默认upcase-region绑定的常用命令M-U.