Comments (16)
Sounds like Atom needs an operator-pending mode.
from vim-mode.
Yes, that might allow for other vim compatibility fixes such as daw
, caw
and the like.
from vim-mode.
Another example is ctX
, where "X" is the variable character marking the end of the change zone.
from vim-mode.
In addition there is the tX
and fX
along with all of its variations: dtX
, yfX
, etc.
from vim-mode.
I'm happy to close this if someone wants to create a new ticket with a better description that incorporates all these things?
from vim-mode.
👍 to the operator pending mode, also feel free to edit the issue description/title. Usually I shy away from editing issue descriptions and titles but I think it's fine in a case like this.
from vim-mode.
There is some semblance of operator pending going on with the @complete
instance variable in operators.coffee, but I think an operator pending mode might make it more explicit and potentially simplify some code. These are the only operators vim officially considers operators - c, d, y, ~, g~, gu, gU, !, =, gq, g?, >, <, zf, g@
I think operators.coffee has a few outliers that we might be able to move to commands.coffee.
If we ever want to implement those multi-character operators, I think we need to start doing timeout stuff. It would actually be awesome if we had direct support for this in atom. For example, I've always bound jk
to Esc
, and binding j k
in my local keymap causes issues in vim-mode :(.
from vim-mode.
Have updated title to "Implement operator-pending mode".
from vim-mode.
@jroes 👍 on a more correct operator pending mode and making things generally more correct.
As for the timeout stuff that's honestly what stopped the progress on these more complex commands. Atom's keybinding infrastructure was never really intended to have multiple separate key presses (ie keypresses are considered independently, not within a state machine). I think we can get it there but it just hasn't been a priority.
from vim-mode.
I'm off to a slow start guys, this is a little challenging (but fun!) :)
So far what I've done:
- I created a
TextObject
subclass ofMotion
for storing all of our new text objects, and anInnerWord
subclass ofTextObject
that selects the current word under the cursor like vim'siw
- I implemented an
operator-pending
mode that looks pretty much exactly like the other modes. - I copied a bunch of keymaps into the
operator-pending
mode map. This felt like a lot of duplication, maybe there is a better way to handle this. - I spent some time trying to see if I needed to make any changes to the meaty part of how the operator stack works. After a lot of toying around, I think I found that we are probably going to need this stack, but the name was confusing me a bit. I renamed several spots from
operator
tooperation
to better communicate that this is a stack of operations that are being performed, these operations may be operators, motions, text objects, or something else. The way I'm thinking ofopStack
is as an internal representation of something like "d2w". I documented this for future code spelunkers. I hope this is in line with the overall project vision. - I was able to bind
i w
on its own invisual-mode
with no special help there sincei
isn't already bound. However, I noticed that in vim you can typeiw
a bunch of times in visual mode and it'll work likew
after the first time. I was going to leave that as a future exercise outside of whatever pull request I make foroperator-mode
So I think this is a small toe-dip in the waters. From here we should be able to implement aw
and several other things simply because the mode has its own context for key bindings and won't interfere with the other bindings. I still think we are going to hit problems where we'll need timeouts though. Hopefully that gets into Atom sooner or later.
Here's a compare for my current branch: jroes/vim-mode@atom:master...jroes:operator-pending
@mcolyer, everyone - what do you think, does this line up with your thinking? At this point all tests pass, so I could make a PR to stop this from turning into a really really big PR, and then we can all make some successive PRs for various text objects and things that should happen in operator-pending
mode.
from vim-mode.
Oh, forgot to mention -- I'm actually not putting us into operator-pending
mode for every valid operator yet. I thought it would be better to do that one at a time as we need it. Doing it all at once brings with it a ton of test failures that will take some time to dig through.
from vim-mode.
Just adding a note about vip
see #111.
from vim-mode.
ping -- anyone have a chance to offer some feedback on my comments above?
from vim-mode.
@jroes, can you make a pull request out of your branch? That will make it a little easier to talk about.
from vim-mode.
Will do @bhuga. It has drifted a bit. I've rebased, but there are some test failures now that I'll have to look through and address.
from vim-mode.
Added in #152
from vim-mode.
Related Issues (20)
- Deprecated selector in `vim-mode/styles/vim-mode.less` HOT 3
- Return in first character with ^ doesn't work HOT 1
- vim-mode 0.65.1 not working at all. HOT 1
- Implement "Auto Indent on Paste" option (aka ]p) HOT 1
- ctrl-x, ctrl-c and ctrl-v shortcuts not working in russian/ukrainian keyboard layouts
- Just not working. HOT 2
- Uncaught TypeError: Cannot read property 'classList' of null HOT 1
- Enable us the command-line mode HOT 1
- Deprecated selector in `vim-mode\styles\vim-mode.less` HOT 1
- Can i use keybinding without delay like in Sublime text HOT 1
- Undo on autocomplete/snippet HOT 1
- After key 's' in visual mode, selection block not canceled HOT 2
- Uncaught NotFoundError HOT 1
- The error was thrown from the vim-mode package. This issue has already been reported HOT 1
- hi atom vim-mode dev HOT 2
- Unable to use dt$ or ct$ in tex file HOT 1
- Uncaught NotFoundError: Failed to execute 'remove' on 'Element': The node to be removed is no longer a child of this node. Perhaps it was moved in a 'blur' event handler?
- Uncaught NotFoundError: Failed to execute 'remove' on 'Element': The node to be removed is no longer a child of this node. Perhaps it was moved in a 'blur' event handler? HOT 2
- can't save file HOT 1
- Uncaught Error: Connection is closed. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-mode.