-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
Suggestion: add support for true/false, on/off, yes/no… #4
Comments
I actually had this idea some time back. This was my attempt at it: https://gist.github.com/1290527. I didn't like all the redundancy in setting up the keywords so I never pursued merging it in. If we could find something a bit more sophisticated, I think it would be good to go. |
But do we actually need anything more sophisticated? My only suggestion is to write that dict in multiple lines (instead of a long single line), with a blank line between unrelated "graph cycles". Other than that, the code seems simple enough, fast enough, and powerful enough to support things like if→elseif→else→if→… And also to support other languages if anyone wants. But I don't know how you implement the "backwards" search. Well, for cycles of 2 items (like all boolean values), it's possible to map the decrement to the increment, and it will work correctly. For cycles of 3 or more items (if/elseif/else), it would require a "forward" dict and a "backward" dict. Anyway, wanna avoid the redundancy? Try something like this (rough algorithm in Python, because I'm not familiar with vim-script syntax or libraries):
|
"Backwards" search is completely ignored and works by coincidence when it's just pairs of keywords. That's the practical problem with the redundancy. Well that, and I want it to be simpler so that users can customize it, if only unofficially. Your algorithm has the right idea. In fact, we can skip the whole hash thing and just iterate over the list of lists. But trying that out revealed what the real problem originally was. The regexp near the end of my gist is statically generated at plugin load time. I'd much rather allow dynamic overrides (think And for the record, incrementing from |
I agree that if/else thing seems nonsensical, I just mentioned because that's what toggle_words.vim also does, even though probably I won't ever use that. But I also mentioned because it was the only 3-cycle that came to my mind (even though that was a silly example). But now I thought about some others that are much more useful:
I'm not sure if iterating over lists is a "better" solution than storing a dictionary (or a pair of dicts, one forward and one backward). Sure, for small lists it will be fast enough; and it is somewhat unlikely that the list will get too big. Well, I believe that using a dictionary will be faster even for any arbitrary quantity of items. About the regexp... Maybe you should use a simple static regexp like this: Okay, nevermind the previous regexp idea. It's not good enough. Just implement something to rebuild the regexp whenever the user wants to interactively customize the plugin. I hope you don't mind this almost brainstorm message. There won't be many of these, anyway. :) |
Do you know about the swapit plugin? It has similar functionality, and I have sent a patch to the author implementing a fallback to speeddating when none of the swaps apply. This works quite well for me; check it out if you're still interested! |
Hey guys, I'm dealing with a horrifying code base and the DB is littered with weekday strings (monday, tuesday, wednesday columns everywhere), and I figured in addition to binding Ctrl+A/X to date strings and toggleable word-pairs, word groups such as the sets of week-of-day strings and month strings can be added to this as well! Edit: Oh wow, @denilsonsa has already mentioned this. Yep, we just need to be able to define these lists in a localized way. |
FWIW day of week already works with |
Awesome, this does work (but only on capitalized full days of the week -- I'll play with it to see if I can get it to work on 3-char versions and also their lowercase brethren). What is the right way to configure this? Should I call |
You'll need to do it in |
okay that makes a lot of sense, thanks |
@denilsonsa Have you tried implementing the lists you mentioned using SwapIt? Either way, integrating such a system with a hashing datastructure for speeddating will be total win (if not feature-creeping speeddating), but I do see a real challenge in how to do the regex matching. |
Sorry, I haven't tried to implement it. On Fri, Mar 13, 2015 at 12:39 PM, Steven Lu [email protected]
Denilson Figueiredo de Sá |
I just tried out |
+1 @tpope |
I found this old plugin called Toggle (github mirror) and it uses an inconvenient shortcut. And there is also toggle_words (github mirror) that does basically the same thing. And then I though: it makes a lot of sense to toggle booleans using
^A
and^X
!So, as a feature request, you could add this feature to speeddating. No need to support everything, just the most common cases:
I'm not sure if toggling if/elseif/else and define/undef is useful.
The text was updated successfully, but these errors were encountered: