Comments (8)
I finally got around to tweaking my configuration to use case-insensitive matches and can confirm they work! Thank you again, Andrew from the past!
from switch.vim.
I don't think there's any way to "preserve case" automatically for all situations. If nothing else, you might actually want to change the case. A much longer discussion on the topic starts here.
Generally, I'd just recommend that you triplicate your definitions with lowercase, titlecase and uppercase versions. Considering you have a large list, I guess you'd prefer some easier way to do that, so maybe something like what I suggest in that thread:
let g:switch_definitions =
\ [
\ ['normalize_case', ['true', 'false']]
\ ]
Though, I'm not sure how relevant this proposal is. Maybe more like:
let g:switch_definitions =
\ [
\ switch#NormalizedCase(['true', 'false'])
\ ]
Or something. Of course, I'd have to actually get around to implementing something like that. What do you think of the idea?
from switch.vim.
Ah, okay, I can imagine that someone might want, depending on the language, to switch between capitalized and non-capitalized strings. Fair enough.
I don't have a strong preference to either option. The former might lend itself to easier scripting, but if the latter isn't noticably slower to call hundreds of times per Vim startup, go with which you believe to be better.
from switch.vim.
The more switches I have in my vimrc
, the less VimL is suitable for them. :P
Fortunately the switch structures are plain arrays and maps, which means I can move them to a JSON file. Mentioning this that if you go with helper methods, then loading switches from JSON won't be that easy.
Just in case: I use a random JSON parser in Vim to load bigger data structures, so I'm not talking about adding JSON support to Switch.vim itself. ;)
from switch.vim.
I've implemented case normalization, in the way I explained, with the switch#NormalizedCase
helper. The commit is 7f19508. If you take a look, you'll notice I've written some documentation on the helper, but also put some info on what the underlying data format is. Which means that you should be able to use this to generate the definitions from JSON as you're doing.
Could you try it out and let me know if it makes sense?
from switch.vim.
Sweet. Will try. Thanks.
Any particular reason you went with underscore prefixed keys instead of something else? Like $type
?
from switch.vim.
No particular reason. Anything I put in there could also be used as a "normal" substitution. Can't say whether one is more common than the other, but worst case scenario I guess you could do something like {_type: 'normal', _definition: ...}
. Although if I decide to do nesting... Well, I'll think about it.
from switch.vim.
I think case normalization is working, so I'll go ahead and close this issue for now.
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.