PyCharm 中的 Ctrl w
很有用。
M-h
(mark-paragraph),应该接近你的需求了
C-M-h试试
C-h f python-mode
看一开始的注释
;; Movement: `beginning-of-defun' and `end-of-defun' functions are
;; properly implemented. There are also specialized
;; `forward-sentence' and `backward-sentence' replacements called
;; `python-nav-forward-block', `python-nav-backward-block'
;; respectively which navigate between beginning of blocks of code.
;; Extra functions `python-nav-forward-statement',
;; `python-nav-backward-statement',
;; `python-nav-beginning-of-statement', `python-nav-end-of-statement',
;; `python-nav-beginning-of-block', `python-nav-end-of-block' and
;; `python-nav-if-name-main' are included but no bound to any key. At
;; last but not least the specialized `python-nav-forward-sexp' allows
;; easy navigation between code blocks. If you prefer `cc-mode'-like
;; `forward-sexp' movement, setting `forward-sexp-function' to nil is
;; enough, You can do that using the `python-mode-hook':
;; (add-hook 'python-mode-hook
;; (lambda () (setq forward-sexp-function nil)))
;; Shell interaction: is provided and allows opening Python shells
;; inside Emacs and executing any block of code of your current buffer
;; in that inferior Python process.
1 个赞
mark para 和 mark func 差的还很远,除非你的函数中间都不空行
这个应该可以加以利用,写一个textobj
vim/vam
C-h python-shell-send-defun 可以用吗?
beginning-of-defun
和 end-of-defun
也可以试试看
原来已经有了
spacemacs 上是 vii/vai
i代表 indent
vim/vam 原来是我自己加的
(evil-define-text-object evil-a-defun (count &optional beg end type)
(evil-select-an-object 'evil-defun beg end type count))
(evil-define-text-object evil-inner-defun (count &optional beg end type)
(evil-select-inner-object 'evil-defun beg end type count))
(define-key evil-inner-text-objects-map "m" 'evil-inner-defun)
(define-key evil-outer-text-objects-map "m" 'evil-a-defun)
mark-defun
(C-M-h)
试了下mark-defun
是可以的,另外evil用户可以用evil-matchit来选中defun/if-else/for等等block:
(use-package evil-matchit
:commands (evilmi-inner-text-object evilmi-outer-text-object evilmi-jump-items)
:init
(general-define-key
:states '(normal visual motion operator)
"M" 'evilmi-jump-items)
(general-define-key
:keymaps '(evil-inner-text-objects-map)
"m" 'evilmi-inner-text-object)
(general-define-key
:keymaps '(evil-outer-text-objects-map)
"m" 'evilmi-outer-text-object)
:config
(global-evil-matchit-mode 1))
请问 'evil-defun 这个参数是干嘛用的,我在 emacs 里面搜索不到
expand-region
就支持啊
evil-defun
既不是函数也不是变量,执行 evil text object,会调用 bounds-of-thing-at-point
-> forward-thing
-> forward-evil-defun
1 个赞
Hey,我建议看下 Emacs: 智能感知和操作光标处的语法对象
尝试下 thing-edit.el
这个完全不限于python。所有地方都可以使用。拷贝剪切替换全部可用。地址、符号,函数,段落,几乎都可以。
另外建议尝试下里面的 thing-replace-xxx 函数。这些函数现在我使用频率超高。真的很好用。
thing-replace-xxx函数是我加的,来源在 thing-edit新功能介绍 感兴趣可以看看。
2 个赞
赞,mark 一下
补充一个:easy-kill
: M-w d
.