GithubHelp home page GithubHelp logo

Comments (6)

divramod avatar divramod commented on June 18, 2024 1

you will get a beer on the next chaos communication camp.

i learned vim in one of your courses at ohm ;-)

from switch.vim.

AndrewRadev avatar AndrewRadev commented on June 18, 2024

Hey Andrew, i really like your plugin! Thx for the awesome work! I use it many times daily.

Thank you for the kind words :).

I want to switch between the following variable declarations:

Try putting this in ~/.vim/ftplugin/sh.vim, so it gets run for every bash file:

let b:switch_custom_definitions =
      \ [
      \   {
      \     '$\(\k\+\)':     '${\1}',
      \     '${\(\k\+\)}':   '"${\1}"',
      \     '"${\(\k\+\)}"': '$\1',
      \   }
      \ ]

The first transforms "$ followed by only keyword charactersinto${..}, the second matches $, then {, then keyword characters, then }`, and you can guess the third.

from switch.vim.

divramod avatar divramod commented on June 18, 2024

Hey Andrew,

thx for your fast reply!

i tested it and it has a little problem with underscores in the var name.

"${OPT_PATH_PATCH}"

is switching to

"${OPTPATHPATCH}"

do you have a hint on how to make it underscore aware?

i will only use uppercase and lowercase letters and underscores in my variable names.

thx again!

from switch.vim.

AndrewRadev avatar AndrewRadev commented on June 18, 2024

To me, this seems like a conflict with some other switch mapping. Is it possible you have the example from the documentation installed that transforms snake_case into camelCase? As I said in the docs:

Note that this particular example is NOT included as a built-in, since it may overshadow other ones and is probably not that useful, either

I'd recommend you only add that example as a buffer-local one for filetypes you tend to use it often, or add it with a different mapping, like I suggest here:

switch.vim/doc/switch.txt

Lines 295 to 306 in 8f76655

let g:variable_style_switch_definitions = [
\ {
\ '\<[a-z0-9]\+_\k\+\>': {
\ '_\(.\)': '\U\1'
\ },
\ '\<[a-z0-9]\+[A-Z]\k\+\>': {
\ '\([A-Z]\)': '_\l\1'
\ },
\ }
\ ]
nnoremap + :call switch#Switch({'definitions': g:variable_style_switch_definitions})<cr>
nnoremap - :Switch<cr>

Could you check if this is, in fact, the problem?

from switch.vim.

divramod avatar divramod commented on June 18, 2024

you were right.

i have it running now.

thx a lot!

this will really give me a timeboost :-)

from switch.vim.

AndrewRadev avatar AndrewRadev commented on June 18, 2024

Excellent, I'm glad to hear I've been managing to recruit people to the Vim side :D. I'll try to remember to collect that beer!

from switch.vim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.