Is it possible without any plugins? Or what's the best plugin for edit python file?
Is it possible without any plugins? Or what's the best plugin for edit python file?
The way I do it is not specific to functions. It will just select a continuous block of Python code:
v]] if what you want to select is below the cursor
v[[ if it is above the cursor.
Just remove one bracket if the cursor is on the first line of the code block you want to select.
I normally use vip or any of the above depending on the need, do not forget that you can always select up (i.e., down =)) to the next occurrence using v/match (followed by Enter to confirm, and possibly n for next). For python, you could look for the next def or for the return (ret is normally enough).
This isn't the fastest at the beginning, but it is very general, use it in any language and also outside coding (md, latex, etc.).
I try to avoid visual, hence for actions like yank, I tend to go to the beginning of the paragraph [[, yank till the end y]] and come back ^o.
All in one, it is [[y]]^o (With ^ standing for control).
For visual you might use [[v]] or some variations like [[v][, [[v]m, or [[v]M.
If your function is long or has many blank lines, using v}}...}}d is pretty slow.
The quickest way I've found (without plug-ins) is zc2dd. The command zc closes the fold under the cursor, so if you are at the function declaration or any line at the outermost indent level, the whole function will fold. Then 2dd (or 3dd if you have two blank lines before/after your function) will remove the whole thing.