5 ms·
Vim's text objects are one of the fundamental things that make using it so awesome. I've had a bit of code in my vimrc that creates "next/previous" text object
by stevelosh 15y ago
Vim's text objects are one of the fundamental things that make using it so awesome.
I've had a bit of code in my vimrc that creates "next/previous" text objects for a while. Someone came along and helped me make it more compact a while ago, but I can't remember who.
It lets you use "din(" for "delete in next parens (on the current line)", which saves a bit of typing.
https://bitbucket.org/sjl/dotfiles/src/1b6ffba66e9f/vim/.vimrc#cl-1023 https://bitbucket.org/sjl/dotfiles/src/1b6ffba66e9f/vim/.vim...
Maybe I should turn it into a pathogen-installable plugin one of these days.
- solutionyogi 15y agoWow. That's a huge vimrc config (1350 lines!) filled with gems, I am going to go through it and steal them for my vimrc! :)
- s3graham 15y agoAh, I've loved this for ever! I didn't know other people did that too. :) noremap H ^ noremap L $ Stealing your K-kill idea too!
- rane 15y agoYou don't find the default H/M/L that useful? To be honest I never really got around using them but it might a nice addition to my vim usage.
- crazydiamond 15y agoNot clear what this does: " Stop it, hash key. inoremap # X<BS># I tried it too. It's in insert mode, so it types an X, backspaces and then types a '#'.
- looklookatme 15y agoI've got something similar in mine; The use-case is to allow indented comments (in languages where '#' is the comment delimiter) Normally, when using auto-indent/smart-indent, pressing '#' on a blank line will change the column to zero, deleting any existing whitespace. By typing a character and deleting it, you override this behavior, allowing you to have comments at the same indentation level as the rest of the code.
- crazydiamond 15y agoSteve You have a line regarding setting "fuoptions". That only works in mac_vim, so you need to put that in a condition.
- iamnearlythere 15y agoCould it be modified to just use di( or dib etc, and still not break anything essential?