[vox-tech] serendipity with vim

Peter Jay Salzman vox-tech@lists.lugod.org
Fri, 2 Apr 2004 06:16:21 -0800


heh.  at 6:15 in the morning, it blew my mind.  it took a few seconds to
register what was going on.

if anybody has any vim tips they'd like to share, i'd love to see a
thread of people's favorite vim tricks.

here's another one i learned just recently:


1 one
2 two
3 three
4 four
5 five
6 six
7 seven
8 eight
9 nine

use line highlighting (shift v) and highlight lines 4, 5, and 6.
type "zf".
you've now "folded" lines 2, 3, 4, 5, and 6:

1 one
+--  5 lines: 2----------------------------------------------------
7 seven
8 eight
9 nine

now use line highlighting to to highlight the first 4 lines.
type "zf"
you've now folded the first four line:

+--  8 lines: 1----------------------------------------------------
9 nine

place the cursor somewhere on the fold.
type "zo" to unfold:

1 one
+--  5 lines: 2----------------------------------------------------
7 seven
8 eight
9 nine

place the cursor somewhere on the fold.
type "zo" to unfold again:

1 one
2 two
3 three
4 four
5 five
6 six
7 seven
8 eight
9 nine


really great for programming.  one of the uses is when i'm editing a
function and need to see another function that's way down in the source
file.  i can bring them "close together" by folding.

previously, i either moved the functions using block cut and copy (ick)
or by using vim's marks (better, but still ick).


zf: fold the highlighted selection.  it can take movement commands too,
   like "zf}" to fold the next paragraph.

zo: open a fold.  the cursor must be on top of the proper fold.

zc: refold the last fold.

what would be nice is if we could have "named folds", like named
registers or named marks.


wouldn't mind hearing other people's tips....   :-)

pete



On Fri 02 Apr 04,  4:43 AM, Issac Trotts <ijtrotts@ucdavis.edu> said:
> On Fri, Apr 02, 2004 at 03:18:36AM -0800, Peter Jay Salzman wrote:
> > it turns out that vim knows what an URL is, and will download the file
> > pointed to by that URL.  another vim coolity.
> 
> Thanks for the tip!
> 
> -- 
> Issac Trotts
> http://mallorn.ucdavis.edu/~ijtrotts
> (w) 530-757-8789
> 
> _______________________________________________
> vox-tech mailing list
> vox-tech@lists.lugod.org
> http://lists.lugod.org/mailman/listinfo/vox-tech

-- 
Make everything as simple as possible, but no simpler.  -- Albert Einstein
GPG Instructions: http://www.dirac.org/linux/gpg
GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E 70A9 A3B9 1945 67EA 951D