问题描述
|
更改矩形大小写的最简单方法是什么?
手册中提到的所有快捷方式都没有谈到这一点。我需要添加自定义绑定吗?而当我们这样做时,如何仅在矩形内搜索?
解决方法
使用
cua-mode
的矩形选择支持很容易:
(setq cua-enable-cua-keys nil) ; enable only CUA\'s rectangle selections
(cua-mode t)
然后,您可以通过按C-RET并移动光标来选择矩形。要对该区域进行大写更改,只需使用通常的upcase-region
命令,默认情况下绑定到M-U。
, 这是upcase-rectangle
的实现,它将大小写更改为全部大写。只需将upcase
替换为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)))))