-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need API to for lines visible in viewport #2771
Comments
Yeah. We need this for zt and zb as well. As far as I can tell there is not even a way to hack it. |
#9143 - will provides a command to move the cursor. We will see if that command is suffice the needs of this issue and take the next step |
@johnfn FYI Listed the cursor move commands in description which are supported now. |
@sandy081 This is step in the right direction, thank you! Unfortunately, though, we can't do everything just by moving the cursor - we need to know the position where e.g. the middle of the screen is to have full support of the Vim commands. (We could hack it by moving the cursor, recording location, then moving back, but that seems like quite the hack.) |
@johnfn Can you please point me to the use cases or Vim commands where you need the middle of the screen positions. |
@sandy081 Sure, any operator combination with M will do the trick. e.g. |
@johnfn Thanks. The new command 'cursorMove' is mainly to support all cursor specific motions. Once I am done with this, we can definitely come up with a solution for various other motions / operations. For more information about this command refer to #9143. It would be great, if you can let me know if there is anything missing support for cursor specific motions. |
I am also going through your Vim Extension Roadmap for what is missing and needing API support. |
@sandy081 Just to make your life harder - there really isn't much of a "cursor-specific" movement in Vim. All cursor commands can be paired with operators in the same way You can feel free to go through the list, but I already culled it down to #8997; I don't think there are any more than that. You can feel free to try to prove my wrong. 😉 |
(Also, keep in mind that we don't just need first and last line - we actually need every screen line, since a command like 10H will bring you to the tenth line from the top. Course, given the position of the top line, retrieving the 10th line below that position won't be too hard. |
@johnfn I see that in Left-right and Up-down motions section of your road map, following commands are not implemented
I think with this cursorMove command these can be implemented now with or without selection |
Basic idea is to come up with a command to support use cases dependent on Screen / View positions just like the one which I mentioned above. |
Again, all motion commands can be combined with operators. So while The same is true of the other motions you listed. |
I think, you can implement
All other motions follow the same I will try to provide examples. |
@sandy081 sorry for comming to this issue too late. I saw you already implemented new APIs for moving Screen positions and they look good to me. The reason that @johnfn asks for position information instead of moving cursors for us is that we are handling cursors ourselves in VSCodeVim. While in other Vim extensions, they actually keep hands off the cursor, they delegate the cursor handling to VS Code. Moving cursor is more generic and let me try the |
Closing this as the new command meets all necessary cursor move requirements |
@rebornix Please note the small change done to the API for consistency and clean
Please adopt to these changes |
Cursor Commands
g0
vg0
g^
vg^
g$
vg$
g_
vg_
gm
vgm
N
view linesgk
N
view lines upvgk
N
view linesgj
N
view lines downvgj
H
vH
M
vM
L
vL
vi has
H
,M
, andL
keybindings that move the cursor based what lines are currently on screen. It's not possible for a Vim-like extension to implement these right now, because the the vscode extension APIs don't expose this information.The text was updated successfully, but these errors were encountered: