Custom text-objects

1 Point

Romain Lafourcade Romain Lafourcade

9 years ago

Adds custom — and easily customizable — text-objects for use with vi, va, ci, ca, yi, ya, di, da, gu, gU, etc.

for char in [ '_', '.', ':', ',', ';', '<bar>', '/', '<bslash>', '*', '+', '%' ]
    execute 'xnoremap i' . char . ' :<C-u>normal! T' . char . 'vt' . char . '<CR>'
    execute 'onoremap i' . char . ' :normal vi' . char . '<CR>'
    execute 'xnoremap a' . char . ' :<C-u>normal! F' . char . 'vf' . char . '<CR>'
    execute 'onoremap a' . char . ' :normal va' . char . '<CR>'
endfor