Comments (9)
Now I caught it.
Given:
= javascript "▐script"
Expected:
= javascript 'script'
Actual:
- javascript "script"
from switch.vim.
Tripped on this again. Why do we even need this?
from switch.vim.
Sorry for not taking care of this sooner, I've been a bit busy.
For this particular issue, I think it makes sense to limit haml switching to only the beggining of the line (with the cursor before or at the sign). Originally, I made it work on the entire line, since it was more convenient, but it can be confusing sometimes. I've pushed a commit that implements the change. Could you try it out for some time and let me know if it feels better?
from switch.vim.
No problem, thanks! But is it really needed? It's just one symbol, you can replace it with ^r=
or something.
from switch.vim.
It works fine.
Here is what became apparent now. To change hashes to new syntax I am doing /=>
and then 'n-n-n-n-' until there is nothing left.
When I change hashrocket from this position:
(:receipt_id ▐=> cashbox_operation.receipt
It works one-way only, after the switch the cursor is too far to the right:
(receipt_id: ▐cashbox_operation.receipt
And that what causes parser to look for other targets. I don't know what is the best behaviour here, but it is certainly something to be aware of.
from switch.vim.
Well, I tried to expand it to include whitespace, but that's not enough -- switching when on the =
leaves your cursor on the first symbol of the value, not on the whitespace preceding it. I tried expanding it to include one non-whitespace symbol after the whitespace (it's a key-value pair, so there will definitely be a value), and that works, but only if the value itself is not switchable. E.g. switching this works:
foo = {
:some_key => bar,
some_key: bar,
}
Because the cursor ends up on "b". But if it's a string, it doesn't (cursor ends up on "
, switches the string quotes):
foo = {
:some_key => "bar",
some_key: "bar",
}
So I don't know if it even makes sense to do it. It will work in some cases, but not in others, so that might be confusing.
Usually when I do this, I just do it on the key itself. So, if you're doing this in bulk, I'd just recommend searching for /\k\s*=>
instead. Or, if you're expecting string keys, even /\S\s*=>
would work just fine. It's more characters to type, but if you're just running it once and replacing it everywhere with an n-n-n-n-
, it shouldn't be a big deal.
No problem, thanks! But is it really needed? It's just one symbol, you can replace it with ^r= or something.
You're right that, in this case, it's not a big deal. Originally I made this for eruby tags, which also have a few prefixes. So, for instance, you can't just go to the beginning of the line, you have to go backwards to <%=
. And doing a T=
wouldn't always work, since there might be an =
sign somewhere else on the line. For haml and slim, it's not so important, although it's still a bit convenient to toggle it while in the middle of something else. With this change, it's definitely not very useful :).
But if this was the core issue, maybe it makes sense for me to put it back the way it was. Your thoughts?
from switch.vim.
To my taste I think it's better to leave it as it is now, it's not too aggressive, yes it sometimes changes strings to symbols after converting hash, but that is not much of a problem.
I get your point about erb, but I am barely using it these days, so I can't comment.
from switch.vim.
After thinking about it for a while I thunk I'd rather had disabled -/= switch for Slim and HAML so you get best of both worlds.
from switch.vim.
Yeah, I guess the -/= switch is not that useful anyway. I've pushed a commit that disables it for now. If anyone has a problem with this, they can open an issue.
from switch.vim.
Related Issues (20)
- Switch.vim pollutes search history HOT 2
- help with a bash switch? HOT 6
- Add case insesitivity HOT 2
- Does not working eruby_tag_type in eruby filetype. HOT 4
- [wiki] Anyone know how to write a substitution for React props? HOT 3
- Invert logical expression, using De Morgan Law HOT 1
- "." repeats always forward, even if the last used command was "SwitchReverse" HOT 2
- Undefined variable: g:switch_builtins and invalid expression error on startup when opening a Ruby file and loading the plugin through NeoBundle HOT 2
- Enable js toggles for typescript, typescript.tsx filetypes HOT 2
- switch#NormalizedCase and word boundaries HOT 3
- increase/decrease number HOT 2
- Switching all the flags at once HOT 2
- Possible to call normal commands in switch definition? HOT 10
- Enable switching booleans anywhere on the line and returning to original cursor position HOT 6
- Introduce a way to set priority/precedence? HOT 9
- Idea: Multiple switch alternatives HOT 3
- Comparison to swapit HOT 2
- can you please add a configuration example for lua HOT 2
- NormalizedCaseWords does not work for capitalized words HOT 2
- Patch to allow reverse action (and count) in lambda substitutions HOT 3
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 switch.vim.