With relativenumber
Turn on relativenumber
with the following:
:set relativenumber
Now, your test case is
1 [
0 (Text),
1 (Text),
2 (Text),
3 ],
Here, the numbers on the left side are not part of the text, it's simple line numbers. See :h rnu
Now, perform the following actions:
- Move the cursor to first
T
- Enable
visual-block
mode with Ctrl-V
- Press
2j
to go 2 line down vertically to the desired T
.
With searching
Your text case looks like the following
[
(Text),
(Text),
(Text),
],
Now, perform the following actions:
- Take the cursor to the first
T
- Enter
visual-block
mode with Ctrl-V
- Search forward for
T
with /T<CR>
- Go to the next
T
with <Ctrl-G>
But I'm guessing what you really want is select the whole column within the indentation. So a more general approach would be the following:
- Take the cursor to the first
T
- Enter
visual-block
mode with Ctrl-V
- Jump to the last line with
}
- Search backward for
T
with ?T<Enter>
Explanation
In case of using relativenumber
, the important part is what vim considers jumps
, see :h jump-motions
. When you pressed }
as you stated in your question, the cursor moved to the first (virtual) column. It may seem like it happened because there is simple no other characters in that line so the cursor had no way to maintain it's column number. But this is the case with all other jump-motions. Vim doesn't consider j
or k
as jump-motions. So, if you use j
or k
to move around in visual-block mode, your (virtual) column position will be maintained.
In case of searching, you're necessarily directed the cursor where to go manually. So, it's a more rigorous process and only to come into play if you're hardfast not to use relativenumber
.