Skip to content

Vim plugin for searching next/prev text objects

Notifications You must be signed in to change notification settings

saulaxel/vim-next-object

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Next Text Object Vim Plugin

This Vim plugin allows you to search forwards or backwards text objects rather than requiring that you be inside them. It is based on a function from Steve Losh's vimrc, with some modifications.

The plugin by default uses the letters 'n', 'l' and maps and . This can be configured.

Works for the following text objects: (, [, {, ', "

In conjunction with operators, allows to make commands as:

  • din( -> delete inside next pair of bracket
  • dil} -> delete inside previous pair of brackets
  • dal" -> delete around previous string

Features


  • Operate in next/previous text object

      Original text ('|' represents cursor position in normal mode):
    
          |foo = bar('span')
    
      Input keys:
    
          foo = bar
    
      Result:
    
          foo = bar('|')
    
  • Select around previously used object

      Original text (after using 'in{' text objec text objectt):
    
          fun1()
          {
              # text
          }
          |
          fun2()
          {
              # text
          }
    
      Input key 1:
    
          <C-h>
    
      Result 1 (▒ means start and end of selection):
    
          fun1()
          {▒
              # text
          ▒}
    
          fun2()
          {
              # text
          }
    
      Input key 2:
    
          <C-l>
    
      Result 2;
    
          fun1()
          {
              # text
          }
    
          fun2()
          {▒
              # text
          ▒}
    

Installation

Download repository and copy every in the corresponding folders or just use a plugin manager as:

Vundle: Add to your .vimrc:

Plugin 'saulaxel/vim-next-object'

Plug: Add to your .vimrc:

Plug 'saulaxel/vim-next-object'

Configuration

  • Change next/previous shortcuts

     let g:next_object_next_letter = 'n'
    
     let g:next_object_prev_letter = 'p'
    
  • Change shortcuts for selecting previously used objects

     let g:next_object_select_next = "<C-l>"
    
     let g:next_object_select_prev = "<C-h>"
    
  • Let the functions wrap the file

     let g:next_object_wrap_file = 1
    

About

Vim plugin for searching next/prev text objects

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published