Code Monkey home page Code Monkey logo

Comments (6)

chaoren avatar chaoren commented on June 16, 2024 1

You can always do something like:

xnoremap io iw
xnoremap ao aw
onoremap io iw
onoremap ao aw

and do cio, where o means original.

from vim-wordmotion.

chaoren avatar chaoren commented on June 16, 2024

Do you mean you want to use ciw on [a_really_huge_variable_using_the_normal_w_vim_motion]?
Why not ci[?

I'm not sure this is necessary.

  1. If you use this plugin's word motions more often, then you use it with the default mappings and nnoremap something else to the regular word motions.
  2. On the other hand, if you use regular word motions more often, then you can use this plugin's word motions with a prefix or something.

You could also consider applying a custom mapping only on the iw and aw commands, so the regular vim word objects are available, but you still use this plugin's word motions by default.

i(, i[, i{, i", iW (WORD not word), etc, seems to cover most cases where you want larger text objects than provided by this plugin.

from vim-wordmotion.

chaoren avatar chaoren commented on June 16, 2024

I'm leaving this open.I will consider it if you can provide reasonable examples where the suggestions I gave above don't work.

from vim-wordmotion.

ninrod avatar ninrod commented on June 16, 2024

You are right. The example was poor because you could circumvent the problem using ci[ or similar bindings. But having a convenient surrounding arround the big word will not always be the case.

let us consider this snippet for a moment:

if [[ -n ${GIT_USER_NAME+x} ]]; then
  git config --global user.name $GIT_USER_NAME
  export GIT_USER_NAME
fi

let us suppose that user wants to refactor GIT_USER_NAME. With vim-wordmotion defaults there is no easy way to do that. Of course that :norm! ciw would function here. But dropping a whole ex-command to achieve the solution does feel clunky. You ct+ if you were on the beggining of the word. But what if the cursor is above the N of git user name? bbct+? clunky.

For completeness sake, I'll drop yet another example:

  local plug_dir=$(realpath -m $really_poorly_named_user_directory)
  if [[! -d $sytem_wide_plug_horrendous_named_dir]]; then
    echo -e "installing ${Yellow}vim${Rst} plugins..."
    vim +PlugInstall +qall
  fi

Now imagine you want to rename those awful named variables. I think now I managed to get the picture across. That's the nagging issue.

from vim-wordmotion.

chaoren avatar chaoren commented on June 16, 2024

This works too:

let g:wordmotion_mappings = { 'iw' : 'ii', 'aw' : '' }

and continue to use ciw for regular words, but use cii for "inner" words.

from vim-wordmotion.

ninrod avatar ninrod commented on June 16, 2024

hum, yeah. The cio bind solves the problem nicely. Thanks for pointing out that free bind, by the way. Finding free bindings like that in vim is an art form.

from vim-wordmotion.

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.