Jump to previous/next matching indentation point? #9863
Replies: 10 comments 3 replies
-
I was surprised that No. 3 wasn't supported already. Being able to jump from any of the first four characters of Maybe we're seeing this working a little differently, but it seems like it would naturally work 'in four directions':
The first visible cell would be the first cell in the same column as the cursor that occurs after any indentation and before the end of the visible line. I'm not sure how to define the end though. Maybe the newline should be included, and possibly trailing whitespace?? The leading line would be the nearest line above that is indented less than the current line. The first child line would be the first line beneath that is indented more than the current line (which may be the child of the current line or a lower sibling). There's a case for only supporting a subset of the four I listed, either the first two, or the first three, just to keep things simple. I don't like the nomenclature I've used here, but do think something like this would be very useful. |
Beta Was this translation helpful? Give feedback.
-
This seems like a duplicate of #1810. Depending on the language, you could use the pre-existing textobjects or A-o to go up the tree-sitter AST. |
Beta Was this translation helpful? Give feedback.
-
Hey, @kirawi. Hope you're well. As I understand #1810, it only permits selecting blocks of equally indented lines. This issue is about moving (jumping) to another line, based on its relationship to the current line. For the sake of simplicity and generality, the behavior is inferred from the indentation, but in practice (at a higher level), it allows you to do things like jump to the line that leads the current block (typically an At a high level, it does a couple of different things, but it functions in terms of indentation, and at that level, makes sense as a single feature/proposal. |
Beta Was this translation helpful? Give feedback.
-
Take this example code (only the indentation is important): for n in numbers
x = n * 2
put x
put numbers If your cursor is on Line 2 or Line 3 somewhere, then #1810 allows you to select Line 2 and Line 3 (because they're at the same level of indentation). This proposal allows you to jump to the start of Line 1 (because it's the leading line of the block that Line 2 and Line 3 belong to), and supports something like the opposite (jumping from Line 1 to the start of its first child (Line 2)). This proposal also allows you to jump from any of the first four columns on Line 1 to the corresponding column on Line 4 (because there's only leading-whitespace in-between), and the exact opposite. It's like code as bullet-points. |
Beta Was this translation helpful? Give feedback.
-
You can flip the head of the cursor and deselect to achieve that as well. The PR #1810 is resolved by also allows you to select the outer indentation. Or you could combine selecting the inner indentation with a single A-o if you really want to focus on only that block and not everything in the outer indentation. This could be further improved by adding more textobjects (e.g. control flow) and implementing "select textobjects" and "next/prev textobject" (there's a tracking issue for this). To jump to the outer column, you can use smart-tab if you're in insert mode to jump out of the scope as well. Your additional suggestions are different from the premise of this issue. No idea if this is fully making sense to you since I'm writing this while very tired. |
Beta Was this translation helpful? Give feedback.
-
Yeah I don't think indentstion based movement is useful compared to tree sitter (especiallyin language which are jot python where indentation is not semantically meaningful). Tree sitter also allows you to select the parent node which can already do want you want (especially if you flip the selection). You can also select the next/previous sibling |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
I think @kirawi accused me of adding stuff that wasn't part of the original proposal, which is probably true. I never meant to do that, and am sorry if that's made this issue more confusing. As I mentioned already, I was surprised that Helix lacked the ability to jump up and down like I described, and assumed (if so) someone would have opened an issue proposing it by now. I came to see, found this issue, which seemed close enough, so I added my two pennies. Sorry for the noise. If we can implement stuff like this ourselves (in |
Beta Was this translation helpful? Give feedback.
-
You're all good. I appreciate your feedback. |
Beta Was this translation helpful? Give feedback.
-
Alright, so I've been fiddling with it. Here's to macros that pretty much does what I intended here (working in 23.10):
In normal mode, enter goes to next indentation, backspace goes to previous indentation. I only tested this with PHP so far, so it might be borked for other languages... |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
It's fairly often that I need to refer to the current scope of my work. This could easily be traversed if Helix had a way to jump to where the current indentation is started/ended. Any further movement from this start/end-point would jump the cursor to the next indentation point.
Example:
logic4
will place the cursor at the starting character ofindent2
.indent1
.indent1
would jump the cursor to the starting character ofoutdent1
.Beta Was this translation helpful? Give feedback.
All reactions