DSL Tips and Tricks :: Vim tips



Some miscellaneous stuff that I've found useful on many occasions....

:split <filename>
Splits the window and opens filename.

:r!<command> add the output of command to the cursor location. It's not always pretty.

^
Move cursor to the first non-blank character of the current line (is better than Home/0 in many cases)

<number>gg
Go to the first non-blank character of line <number>.

When cursor is over a number, Ctrl+a increases the number, Ctrl+x decreases.

I'm sure there were more that I use a lot, and some more unusual, but I haven't waken up yet =op

Quote
:r!<command> add the output of command to the cursor location. It's not always pretty.

That's my favorite way for making and editing playlists and other lists.

:r! find [appropriate flags/paths] | grep [content I want]

So for all my Schubert MP3s (my mp3s are all lower case)

:r! find ~/ | grep schubert

Then edit anything that needs to be fixed and save.

Vim's power also has it's downside.  For example, I've found it difficult to correct a bug in a function when there's another copy of it pasted somewhere else in my code  :(
Quote
I've found it difficult to correct a bug in a function when there's another copy of it pasted somewhere else in my code
I've read this a couple times, and I'm still not sure what you're saying. You're talking about vim functions?
In any case, I don't understand why you would have the same function twice in the same code anyway. The whole reason behind using functions is to prevent the need for duplicate code.

Quote (mikshaw @ Dec. 14 2007,09:22)
Quote
I've found it difficult to correct a bug in a function when there's another copy of it pasted somewhere else in my code
I've read this a couple times, and I'm still not sure what you're saying. You're talking about vim functions?
In any case, I don't understand why you would have the same function twice in the same code anyway. The whole reason behind using functions is to prevent the need for duplicate code.

The point was that it's easy to inadvertantly push the "wrong" key during the process of coding, with unexpected results.  That happened to me recently.  After a half hour of trying to figure out why a simple function wouldn't work, I found a copy of it pasted way down in my code!
Next Page...
original here.