This plugin provides text objects for text inside “double curly quotes” and ‘single curly quotes.’ It also makes it easier to move through text that contains curly quotes. (The information in the README may be abbreviated. See the documentation for fullest details.)
This plugin relies on vim-textobj-user. You must also install that plugin.
Neither vim-textobj-user nor this plugin should require any special treatment. You can use your favorite Vim plugin manager. For neovim and recent versions of vim, you should also be able to simply clone the directories in your pack path.
||inside double curly quotes|
||inside double curly quotes and the quotes themselves|
||inside single curly quotes|
||inside single curly quotes and the quotes themselves|
" Cursor is at | “This is not| a love song.” cic “|” “T|his is not a love song.” dac | ‘This i|sn’t a love song either.’ diC ‘|’
In the last example, the text object looks past the apostrophe to find the entire quotation.
||move to the next double curly quotes|
||move to the previous double curly quotes|
||move to the next single curly quotes|
||move to the previous single curly quotes|
" Cursor is at | I| said, “This is not a love song.” But someone replied angrily, “It is! It *is* a love song!” ]c I said, “|This is not a love song.” But someone replied angrily, “It is! It *is* a love song!” ]c I said, “This is not a love song.” But someone replied angrily, “|It is! It *is* a love song!” [c I said, “|This is not a love song.” But someone replied angrily, “It is! It *is* a love song!”
If you don’t want the default mappings, add this to your vim
Then you can create whatever mappings suit you. For example:
" If you like q (for ‘quote’) more than c (for ‘curly’): omap aq <Plug>(textobj-curly-double-a) omap iq <Plug>(textobj-curly-double-i) xmap aQ <Plug>(textobj-curly-single-a) xmap iQ <Plug>(textobj-curly-single-i) map ]q <Plug>(textobj-curly-double-n) map [q <Plug>(textobj-curly-double-p) map ]Q <Plug>(textobj-curly-single-n) map [Q <Plug>(textobj-curly-single-p)
There are two plugins that do nearly all of what this one does, plus a whole lot more. I wrote this to learn, and also because I wanted something more minimal. But I encourage you to take a look at vim-textobj-quote and vim-sandwich, especially if you want further features.
If you find a bug, I would love to hear about it. Please email me at firstname.lastname@example.org. I would also love to hear from you if you have a better way to do something that the plugin already does. (I’m no expert at VimL, and I’m always glad to learn more.)
You’re welcome to contact me if you want a new feature, but I’m not likely to say yes. My goal was to make this as minimal as possible. The plugin has the features that I consider essential, and I’m unlikely to add any others.
Kana Natsuno’s vim-textobj-user does almost all the heavy lifting for this plugin. vim-textobj-user makes it extremely simple to create new text objects. I encourage you to check it out, as well as the listing of all the new text objects that Kana and others have built with it. I am very grateful to Kana for his many plugins.
Thanks also to June Gunn for vader.vim. He made it almost fun to test VimL.
BSD 3-Clause license: for details see LICENSE.txt in this repo or the version online.