The textobject plugin to do well with each delimited part of a string.
Vim script
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
autoload/textobj
doc
plugin/textobj
test
.travis.yml
README.md
appveyor.yml

README.md

textobj-delimited

Build Status Build status

The textobject plugin to do well with each delimited parts of string.

Brief explanation

This textobject provides the keymappings to select a part of a delimited string. id, ad, iD, aD is used in default. Please see following examples and doc/textobj-delimited.txt.

Examples

------------------------------------------------
 key input: did
  #                    #         : cursor
 'foo_bar_baz'   ->   '_bar_baz'
------------------------------------------------
 key input: did
      #                    #     : cursor
 'foo_bar_baz'   ->   'foo__baz'
------------------------------------------------
 key input: did
          #                   #  : cursor
 'foo_bar_baz'   ->   'foo_bar_'
------------------------------------------------
 key input: d1id
      #                #         : cursor
 'foo_bar_baz'   ->   '_bar_baz'
------------------------------------------------
 key input: d2id
  #                        #     : cursor
 'foo_bar_baz'   ->   'foo__baz'
------------------------------------------------
 key input: d3id
  #                           #  : cursor
 'foo_bar_baz'   ->   'foo_bar_'
------------------------------------------------
 key input: dad
  #                    #         : cursor
 'foo_bar_baz'   ->   'bar_baz'
------------------------------------------------
 key input: dad
      #                    #     : cursor
 'foo_bar_baz'   ->   'foo_baz'
------------------------------------------------
 key input: dad
          #                  #   : cursor
 'foo_bar_baz'   ->   'foo_bar'
------------------------------------------------
 key input: d1ad
      #                #         : cursor
 'foo_bar_baz'   ->   'bar_baz'
------------------------------------------------
 key input: d2ad
  #                        #     : cursor
 'foo_bar_baz'   ->   'foo_baz'
------------------------------------------------
 key input: d3ad
  #                          #   : cursor
 'foo_bar_baz'   ->   'foo_bar'
------------------------------------------------

When delimited parts are being selected in visual mode, this textobject behave differently from usual, expanding selection area like viwiwiw... Assume the situation as following:

       |<-->|        : selected area
abcdef_ghijkl_mnopqr

If you use id, then you will get:

       |<--------->| : selected area
abcdef_ghijkl_mnopqr

If you use iD, then you will get:

|<--------->|        : selected area
abcdef_ghijkl_mnopqr

At the beginning of a word, ad and aD work tricky. Look the following examples.

If you use dad, the cut strings are different for '_abc_def_ghi_' and 'abc_def_ghi'.

         #                     #        : cursor
        _abc_def_ghi_    ->    _def_ghi_         (cut '_abc')

        #                      #        : cursor
        abc_def_ghi      ->    def_ghi           (cut 'abc_')

Thus, if a word has ended delimiters like '_abc_def_ghi_', ended delimiters would be preserved. If a word has no ended delimiters like 'abc_def_ghi', ended delimiters would not appear. dad keeps the exsistence/nonexistence of ended delimiters.