News for hackers. Stuff that matters.
Re:Vim clutch by weaksauce on Thursday June 21, 2012 @12:45PM (#4142875)
You can start thinking in vim by reading this answer on stack overflow: http://stackoverflow.com/a/1220118

Moving word wise,(w,e) is used a lot.

Next occurrence of word under cursor is useful. *,#

Learning effective macros is extremely useful.

di" is one of my favorite commands. Delete everything inside the quotes not including the quotes.

Put inoremap jj <Esc> into your .vimrc so that you can press jj quickly in insert mode instead of Esc.

Remap your arrow keys to nop and get proficient with it; this feels like I am editing super fast. A lot of editor time can be spent with your hands on home row without ever leaving.

Re:Vim clutch by ehsanu1 on Thursday June 21, 2012 @12:55PM (#4142933)
di" is one of my favorite commands. Delete everything inside the quotes not including the quotes.

You usually want to replace what's inside the quotes, so hence use ci"

cit is pretty nice for replacing a tag's inner html. And of course this works with parentheses - ci( - and brackets - ci[ - and curly braces and single quotes and angle brackets.. I love vim :)

Re:Vim clutch by orthecreedence on Thursday June 21, 2012 @02:07PM (#4143364)
Wow cit...I've been wondering if this exists for a year now. I remember reading about it when I first started learning vim but it somehow eluded me afterwards. Thanks!

I use ci{ all the time for functions and CSS. It's like magic. Whenever I'm using something like nano, I'll instinctively type what looks like a long string of gibberish: "jjjddo [oh crap] <bs><bs>..."

Once you really start getting used to the language, it makes it frustrating to use anything else.

Re:Vim clutch by lloeki on Thursday June 21, 2012 @03:57PM (#4143914)
> Wow cit...I've been wondering if this exists for a year now

Then marvel at vim-surround: cs"', cs)(, or cst<foo>, or (Shift-)v select visually S <mytag>, and argtextobj: cia and daa. Those are the two plugins that I really miss on a stock vim.

[0] https://github.com/tpope/vim-surround.git [1] https://github.com/vim-scripts/argtextobj.vim

Re:Vim clutch by weaksauce on Thursday June 21, 2012 @02:30PM (#4143486)
> Once you really start getting used to the language, it makes it frustrating to use anything else.

Indeed... That is why I have been contributing to Xvim[1] for Xcode it's so nice to have vim bindings in Xcode.

[1] https://github.com/JugglerShu/XVim

Re:Vim clutch by weaksauce on Thursday June 21, 2012 @01:45PM (#4143249)
Yeah you are right; I use c more than d. The a command is also very useful.
Re:Vim clutch by orthecreedence on Thursday June 21, 2012 @02:10PM (#4143388)
I'm going to try this: inoremap jj <Esc>

I normally use C-c. Is there a way to make the time between j...j to be really short? Like the delay for it to count as a double press? I'd like to reduce any chance of accidental typing (although I can't see any reason I'd type "jj" a lot).

Re:Vim clutch by mattkirman on Thursday June 21, 2012 @02:25PM (#4143454)
You could probably try setting timeoutlen to something like 500 milliseconds (or whatever feels comfortable). Bear in mind though that this is a global setting.
Re:Vim clutch by weaksauce on Thursday June 21, 2012 @02:27PM (#4143470)
yes you can set the timeout delay to be something very small see :help timeoutlen. It defaults to 1000ms but you are free to change it. If you are typing in insert mode and you press j it will delay but if you press another key that is not bound to anything after j it will just insert the j and the other key.
Re:Vim clutch by grayrest on Thursday June 21, 2012 @02:24PM (#4143450)
The setting applies to all maps. :help timeoutlen
Re:Vim clutch by weaksauce on Thursday June 21, 2012 @04:39PM (#4144079)
addendum to the above advice from me:

How could I forget the substitution command? <range> s/old/new/g (g == all occurrences on the line.) range can be a lot of different options. The most useful <range> options in my experience would be:

%(all lines in the file),

select something in visual mode and press :,

-x, +y for + and - x and y lines from where you are.

exact range is not that useful in my daily use.

The other thing to note about the s command is that you can use other delimiters instead of / I like to use #

% s#/some/path/to/a/file#/another/path/#g works just fine and is much more readable than % s/\/some\/path\/to\/a\/file/\/another\/path\//g