You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Move to view line first non white space character g^
Select till line first non white space character vg^
Move to view line end g$
Select till view line end vg$
Move to view line last non white space character g_
Select till view line last non white space character vg_
Move to view line middle gm
Select till view line middle vgm
Move up N view lines gk
Select till N view lines up vgk
Move down N view lines gj
Select till N view lines down vgj
Move to first non white space character of Nth line from the top of the view H
Select till first non white space character of Nth line from the top of the view vH
Move to first non white space character of center line of the view M
Select till first non white space character of center line of the view vM
Move to first non white space character of Nth line from the bottom of the view L
Select till first non white space character of Nth line from the bottom of the view vL
vi has H, M, and L 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.
Reacted by Grant Mathews, Sébastien Pierre and Amin Roosta
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.)
Sandeep Somavarapu (@sandy081) Sure, any operator combination with M will do the trick. e.g. dM will delete characters until the middle of the screen. vM will select until the middle of the screen. (The same is true of the top and bottom lines with H and L, respectively).
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.
Sandeep Somavarapu (@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 M could be to transform them into deletions or selections, so the position is pretty much a global necessity. If just moving the cursor is easier, that's fine for now - it's certainly better than nothing.
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.
Again, all motion commands can be combined with operators. So while g0 works (yay!), vg0 (select to the position of g0) and dg0 (delete to the position of g0) are missing.
Sandeep Somavarapu (@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 Grant Mathews (@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 inSelectionMode you mentioned. Will give you update about newly added API real quick.
Activity
johnfn commentedon Jun 18, 2016
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.
sandy081 commentedon Jul 12, 2016
#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
sandy081 commentedon Jul 19, 2016
Grant Mathews (@johnfn) FYI Listed the cursor move commands in description which are supported now.
johnfn commentedon Jul 19, 2016
Sandeep Somavarapu (@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.)
sandy081 commentedon Jul 19, 2016
Grant Mathews (@johnfn) Can you please point me to the use cases or Vim commands where you need the middle of the screen positions.
johnfn commentedon Jul 19, 2016
Sandeep Somavarapu (@sandy081) Sure, any operator combination with M will do the trick. e.g.
dMwill delete characters until the middle of the screen.vMwill select until the middle of the screen. (The same is true of the top and bottom lines with H and L, respectively).sandy081 commentedon Jul 19, 2016
Grant Mathews (@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.
sandy081 commentedon Jul 19, 2016
I am also going through your Vim Extension Roadmap for what is missing and needing API support.
johnfn commentedon Jul 19, 2016
Sandeep Somavarapu (@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
Mcould be to transform them into deletions or selections, so the position is pretty much a global necessity. If just moving the cursor is easier, that's fine for now - it's certainly better than nothing.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. 😉
johnfn commentedon Jul 19, 2016
(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.
sandy081 commentedon Jul 19, 2016
Grant Mathews (@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
sandy081 commentedon Jul 19, 2016
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.
johnfn commentedon Jul 19, 2016
Sandeep Somavarapu (@sandy081)
Again, all motion commands can be combined with operators. So while
g0works (yay!),vg0(select to the position of g0) anddg0(delete to the position ofg0) are missing.The same is true of the other motions you listed.
sandy081 commentedon Jul 19, 2016
Grant Mathews (@johnfn)
I think, you can implement
vg0anddg0using this newcursorMovecommandcursroMove({to: 'lineStart'})cursroMove({to: 'lineStart', inSelectionMode: true})cursroMove({to: 'lineStart', inSelectionMode: true}); /*Select the text. Now write logic on doc text editor to delete the selected text */All other motions follow the same
I will try to provide examples.
rebornix commentedon Jul 19, 2016
Sandeep Somavarapu (@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 Grant Mathews (@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
inSelectionModeyou mentioned. Will give you update about newly added API real quick.sandy081 commentedon Jul 22, 2016
Closing this as the new command meets all necessary cursor move requirements
sandy081 commentedon Jul 25, 2016
Peng Lyu (@rebornix) Please note the small change done to the API for consistency and clean
amounttovalue.Please adopt to these changes