Wednesday, May 21, 2014

Re: new vim user

BPJ wrote:
> My 'problem' is that I can't by any stretch of imagination think
> of what's sjumped over by W as a 'word' -- it's usually at least
> one word and then some punctuation. I'm probably a dinosaur for
> havings so restrictive a view of what a 'word' is, but so be it.
> I guess I could rephrase it as "W: whitespace-delimited chunk".

Don't think of what is jumped over, think of what it finds. 'W' jumps
to the start of the next word, whatever jumble is in the way. I often
use 'W' for header editing, but in code I find it not as useful as
the find character commands:

f find forward
F find backward
t go to character
T go to character backwards
; repeat last f, F, t, or T
, repeat last f, F, t, or T but in opposite direction

$string = sprintf("example %s line, for explanations\n", $perl);

With the cursor on the first character of the example line, "3fs" will
jump to the "s" in "%s". From there ";" jumps to the last letter in
explanations. "tp" jumps to the "$" before "perl", and "cfl" replaces
up to the last letter in "$perl".

Using "f" / "t" appropriately lets me leverage the value of "n" and "."
to find things to change and then repeat my last edit. The "cfl" edit
starting from the "$" is the same change even if the line looks like
one of these:

$perl = 'Perl, ';
$perl.=$version;
$perl_version = $perl;
$string = sprintf("example %s line%s\n", $perl, $is_plural);

Myself, I never could get 'S' to sink in to my mind. 's', delete
current chararacter and start inserting, makes sense with the
mnemonic of "change a word into a plural", particularly "y" => "ies"
plurals. The line mode change for 'S', which is just a synonym for
'cc' never felt right. Consequently I've usually just remapped it
(:map) in most of my .exrc / .vimrc files.

Elijah

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: