Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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/.vim...

Maybe I should turn it into a pathogen-installable plugin one of these days.



Ah, 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!


You 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.


Wow. That's a huge vimrc config (1350 lines!) filled with gems, I am going to go through it and steal them for my vimrc! :)


Not 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 '#'.


I'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.


Steve You have a line regarding setting "fuoptions". That only works in mac_vim, so you need to put that in a condition.


Could it be modified to just use di( or dib etc, and still not break anything essential?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: