> > Nice idea, certainly useful! I'm not sure whether this should be > > implemented in the C code, though, as it could also be done with > > Vimscript. > > It may as well be in the C code alongside all of the other text > objects. Notice the cases just below his patch which are waiting to > be implemented.
I agree that it should be done in the same place as the rest of the text objects. However, I'm curious how it would be implemented in vimscript? I didn't know it was even possible to implement something like text objects in vimscript. > One suggestion: How about changing 'ii' so that it excludes empty > lines at the beginning and end of the buffer, similar to what the > other text objects do? I don't like it when outer and inner text > object versions are identical. I guess consistency would be nice. I've attached an updated patch.
Index: runtime/doc/motion.txt
===================================================================
*** runtime/doc/motion.txt (revision 1425)
--- runtime/doc/motion.txt (working copy)
***************
*** 650,655 ****
--- 650,662 ----
Special case: With a count of 2 the quotes are
included, but no extra white space as with a"/a'/a`.
+ aa *v_aa* *aa*
+ Shortcut to select the entire buffer.
+
+ ii *v_ii* *ii*
+ Like aa, but ignore white space at the beginning and
+ end of the buffer.
+
When used after an operator:
For non-block objects:
For the "a" commands: The operator applies to the object and the white
***************
*** 692,697 ****
--- 699,705 ----
"dap" delete a paragraph *dap*
"diB" delete inner '{' '}' block *diB*
"daB" delete a '{' '}' block *daB*
+ "daa" delete all text from the buffer *daa*
Note the difference between using a movement command and an object. The
movement command operates from here (cursor position) to where the movement
Index: src/normal.c
===================================================================
*** src/normal.c (revision 1425)
--- src/normal.c (working copy)
***************
*** 8954,8959 ****
--- 8954,8963 ----
flag = current_quote(cap->oap, cap->count1, include,
cap->nchar);
break;
+ case 'a': /* "aa" = whole buffer */
+ case 'i':
+ flag = current_buffer(cap->oap, include);
+ break;
#if 0 /* TODO */
case 'S': /* "aS" = a section */
case 'f': /* "af" = a filename */
Index: src/search.c
===================================================================
*** src/search.c (revision 1425)
--- src/search.c (working copy)
***************
*** 4491,4496 ****
--- 4491,4535 ----
return OK;
}
+ /*
+ * Select entire buffer.
+ */
+ int
+ current_buffer(oap, include)
+ oparg_T *oap;
+ int include; /* TRUE == include white space */
+ {
+ int start = 1;
+ int end = curbuf->b_ml.ml_line_count;
+
+ if (!include)
+ {
+ while (linewhite(start))
+ start++;
+ while (linewhite(end))
+ end--;
+ }
+
+ #ifdef FEAT_VISUAL
+ if (VIsual_active)
+ {
+ VIsual.lnum = start;
+ VIsual_mode = 'V';
+ redraw_curbuf_later(INVERTED); /* update the inversion */
+ showmode();
+ }
+ else
+ #endif
+ {
+ oap->start.lnum = start;
+ oap->start.col = 0;
+ oap->motion_type = MLINE;
+ }
+ curwin->w_cursor.lnum = end;
+ curwin->w_cursor.col = 0;
+ return TRUE;
+ }
+
#endif /* FEAT_TEXTOBJ */
#if defined(FEAT_LISP) || defined(FEAT_CINDENT) || defined(FEAT_TEXTOBJ) \
pgpvX4m8xbgJM.pgp
Description: PGP signature
