Comments (2)
Thank you for your kind reply. I appreciate it.
The command %s/if true; then/if false; then/g
is exactly what I do always in the situation like this. And I was tired of typing this every time I needed it. Using your library, which is very helpful !, I just thought it would be nice to switch those flags in a single command.
But, you are right. That kind of functionality could cause other side-effects. We should not change it.
The commands you kindly proposed, by the way, look fit my needs. I will try it.
Thank you very much.
from switch.vim.
It's an interesting idea, but I have a hard time imagining how it would work, exactly. The plugin looks for the text under the cursor and looks for what pattern the text matches. For instance, for the if true
example for bash, it would match \C\<true\>
.
What I could do is provide a command that replaces it, and then searches to replace the same pattern throughout the same file. But this would affect every true
, not just the if true
parts, so if you have any other usage of true
(even in strings) it would also change and that might be unexpected.
Additionally, for a change like this, it would be good if the range of the operation was controllable, it's rare to have an action that replaces in the whole file. If I wanted to achieve this, I'd use something like %s/if true; then/if false; then/g
. But I can also run this substitution on a limited area by selecting visually the first two blocks for example. With a "global switch", the cursor would have to be positioned on something first and then it would be impossible to select an area to operate on.
Can you describe how you'd imagine this global switch action to work in terms of interface? For now, I feel like this is not a good fit for the plugin, and I'd recommend creating a bash-specific command to do this, like putting these two commands in ftplugin/sh.vim
:
command! -buffer -range=% Disable <line1>,<line2>s/if true; then/if false; then/g
command! -buffer -range=% Enable <line1>,<line2>s/if false; then/if true; then/g
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
- 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.