Giter VIP home page Giter VIP logo

vim-textobj-variable-segment's Introduction

vim-textobj-variable-segment

A vim plugin providing a single text object (on iv and av) for variable segments. A variable segment is defined to be a substring in any identifier character followed by an underscore ("snake case") or a lowercase identifier character followed by an uppercase character ("camel case").

E.g.:

foo_ba|r_baz    -> civquux -> foo_quux_baz
QU|UX_SPAM      -> civLOTS_OF -> LOTS_OF_SPAM
eggsAn|dCheese  -> civOr -> eggsOrCheese
_privat|e_thing -> civone -> _one_thing

foo_ba|r_baz    -> dav -> foo_baz
QU|UX_SPAM      -> dav -> SPAM
eggsAn|dCheese  -> dav -> eggsCheese
_privat|e_thing -> dav -> _thing

It will also preserve case for small camels when initial segments are deleted (with av):

_g|etJiggyYo   -> dav -> _jiggyYo

Requires vim-textobj-user.

vim-textobj-variable-segment's People

Contributors

julian avatar konfekt avatar magejohn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

vim-textobj-variable-segment's Issues

Starting from first variable segment deletes most of the previous word

Consider the following text:

Should not get touched but_it_will

If I put my cursor on the b in but, and do dav, the following text results:

Should not get t but_it_will

Isn't that odd? I've tried it with other conventions (e.g., CamelCase) as well.

I'm using the latest version (I updated my Vundle packages today) using Vim 7.4.0.

License?

This is a cool plugin, thanks!

Could you please add a license to clarify how it can be used, e.g. the Vim license or Apache 2.0?

`.` does not work with counts

Consider the following testing text:

the_quick_brown_fox
the_quick_brown_fox

Position the cursor on the first q, and type c2ivslow_red. After leaving insert mode, we have:

the_slow_red_fox
the_quick_brown_fox

Now, position the cursor on the second q, and hit . (assuming you have repeat.vim installed). The output should be:

the_slow_red_fox
the_slow_red_fox

Instead, it is:

the_slow_red_fox
the_slow_red_brown_fox

In other words, the count doesn't get carried along for the repeating.

Doesn't work with repeat.vim

Consider a string:
_my_testing_string

Put your cursor on the first m, and type dav. Result:
_testing_string

Excellent! Now hit . to repeat the operation (assuming you have repeat.vim installed). I want to see:
_string
Instead, I actually see:
_ting_string

Apparently, the "thing to repeat" in this case is something like 3x. (Further support: I notice . deletes 3 characters wherever I place the cursor.)

Instead, i want it to repeat the operation dav.

Moving through variable segments

It would be nice to move forwards and back by variable segments . I just got into vim and vimscript, I looked at the code for a while and read the documentation but couldn't really figure it out. I saw that it would require setting move-n-function and move-p-function but I wasn't sure how to set up a keybinding and how to set up the dictionaries like that.

make plugin bundle compliant

Hi,

I just wanted to ask whether you could move your plugin structure from

./plugin/textobj/*

to

./plugin/textobj/*

in order to make it more compliant with often used bundlers like Pathogen, Vundle or NeoBundle

Thanks in advance :)

Allow for other delimiter?

Maybe this is too much to do, but for instance, in R the style guide I follow dictates that multi word variables be written as

multi.word.var

I would love to be able to add '.' to the list of delimiters so that this works. Currently doing dav when the cursor is on m' just deletes the whole word. I'd like it to leave word.var instead

Help not indexed by :helptags

After :helptags ALL, the help for the plugin should show up in :help local-additions, but it doesn't.

I believe the cause of this is that the help file does not have a proper title line. I changed line 1 of doc/vim-textobj-variable-segment.txt from:

vim-textobj-variable-segment.txt

to:

*vim-textobj-variable-segment.txt* Text object for variable segments

and that solves the problem.

Single-character CamelCase segments seem not to work

Examples:

  1. Start with aBadTime. Place cursor on B. Type civGood<ESC>. Result should be aGoodTime. Instead, I get GoodBadTime. (Rather unexpected: the character under the cursor is not included in the variable segment!)
  2. Start with AgainABadTime. Place cursor on B and type the same command. Result should be AgainAGoodTime. Instead, I get AgainGoodTime. (Looks like two variable segments, A and Bad, got conflated.)

Doesn't take a count

Consider a string:
_my_testing_string

Put your cursor on the first m, and type d2av. I want to see:
_string
Instead, I actually see:
_testing_string.

Also, forgot to mention: thanks for this plugin =)
It really makes my life easier on a daily basis since I installed it a few days ago.

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.