Using the attached .vimrc
, open sample.py
.
First, class
/def
motions. With the cursor at row 1, column 1, ]]
should move your cursor to row 15, col 1. ]]
again will move you to row 19, column 1. [[
will move you back to row 15, column 1. Reset to row 1, column 1 with gg
. Repeat with ]C
and [C
and it should behave the same as with ]]
and [[
, which I find surprising, but it preserves existing behavior so I will keep it.
Now def
motions. Reset to row 1, column 1, via gg
. ]M
should move you to row 2, column 1. ]M
again should move you to row 5, column 1. [M
should reverse this, moving you to row 2, column 1.
Now text objects. We will use visual selection to show text objects, but not change the file. Move the cursor to row 6, column 1. viM
should select inside the current method (i.e. just selecting row 6). Escape out of that selection. vaM
should select around the current method, that is, rows 5, 6 and 7.
Without this patch, any method prefixed with async
will be skipped by these motions and text objects.
Open this in vim, with the patch I supplied, and use some combination of:
]]
to move to the next top-level class or def (async or not), [[
to move to the previous.
]C
to move to the next top-level class (or def, which is weird behavior, but preserving pre-existing weirdness), [C
to move to the previous.
]M
to move to the next def, async or not, [M
to move to the previous.
And for text objects, any of v
, c
, d
, etc and then iC
to get the inside of a class, aC
to get all around a class, iM
to get the inside of a def (sync or async), and aM
to get the outside of a def (sync or async). I tend to use v
as it's least destructive, and clearly shows what the plugin identifies as "in" or "around".