a" and a' grab extraneous whitespace
Brought to you by:
err
When using v, c, or d (highlight, change, or delete), then a (around) quotation marks (", ', or backtick), extraneous whitespace around the quoted text will get highlighted or deleted, unlike what happens with [], {}, etc.
Examples are below on what gets highlighted/changed/deleted (using generic "highlighted" below) when running a command while the cursor is on "test".
// BAD $var = 'test'; // 'test' is highlighted *as well as the space before it* $var = "test"; // (same as above) $var = `test`; // (same as above) $var = "test" ; // "test" is highlighted *as well as the space after it*, but not the space before it // GOOD $var = [test]; // [test] is highlighted, and not the space before it $var = (test); // (same as above) $var = {test}; // (same as above) $var = <test>; $var = [test] ; // [test] is highlighted, and not the space before or after it
I would expect quotation marks to follow the same "a" rules as brackets.
Yeah, I would expect that too. But it doesn't. Here's the help taken from vim8.0. In particular, note the sentence "Any trailing white space is included, unless there is none, then leading white space is included."
Gotcha - I guess that rule makes sense for non-coding situations. At least I understand the justification and won't be cursing you for some off-by-one error or something!
And in case anyone else stumbles across this, here's a link for the documentation:
http://vimdoc.sourceforge.net/htmldoc/motion.html#v_aquote