summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/eval.txt18
-rw-r--r--src/eval.c1
-rw-r--r--src/normal.c31
-rw-r--r--src/version.c2
-rw-r--r--src/vim.h3
5 files changed, 52 insertions, 3 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 6857ee519..81c526963 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1,4 +1,4 @@
-*eval.txt* For Vim version 7.1. Last change: 2007 Sep 25
+*eval.txt* For Vim version 7.1. Last change: 2008 Jan 04
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1401,10 +1401,24 @@ v:mouse_col Column number for a mouse click obtained with |getchar()|.
This is the screen column number, like with |virtcol()|. The
value is zero when there was no mouse button click.
+ *v:operator* *operator-variable*
+v:operator The last operator given in Normal mode. This is a single
+ character except for commands starting with <g> or <z>,
+ in which case it is two characters. Best used alongside
+ |v:prevcount| and |v:register|. Useful if you want to cancel
+ Operator-pending mode and then use the operator, e.g.: >
+ :omap O <Esc>:call MyMotion(v:operator)<CR>
+< The value remains set until another operator is entered, thus
+ don't expect it to be empty.
+ v:operator is not set for |:delete|, |:yank| or other Ex
+ commands.
+ Read-only.
+
*v:prevcount* *prevcount-variable*
v:prevcount The count given for the last but one Normal mode command.
This is the v:count value of the previous command. Useful if
- you want to cancel Visual mode and then use the count. >
+ you want to cancel Visual or Operator-pending mode and then
+ use the count, e.g.: >
:vmap % <Esc>:call MyFilter(v:prevcount)<CR>
< Read-only.
diff --git a/src/eval.c b/src/eval.c
index 8f6fcf37c..aff284e0d 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -345,6 +345,7 @@ static struct vimvar
{VV_NAME("mouse_win", VAR_NUMBER), 0},
{VV_NAME("mouse_lnum", VAR_NUMBER), 0},
{VV_NAME("mouse_col", VAR_NUMBER), 0},
+ {VV_NAME("operator", VAR_STRING), VV_RO},
};
/* shorthand */
diff --git a/src/normal.c b/src/normal.c
index f5b76514b..f2c008982 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -141,6 +141,9 @@ static void nv_redo __ARGS((cmdarg_T *cap));
static void nv_Undo __ARGS((cmdarg_T *cap));
static void nv_tilde __ARGS((cmdarg_T *cap));
static void nv_operator __ARGS((cmdarg_T *cap));
+#ifdef FEAT_EVAL
+static void set_op_var __ARGS((int optype));
+#endif
static void nv_lineop __ARGS((cmdarg_T *cap));
static void nv_home __ARGS((cmdarg_T *cap));
static void nv_pipe __ARGS((cmdarg_T *cap));
@@ -7180,6 +7183,9 @@ nv_optrans(cap)
{
cap->oap->start = curwin->w_cursor;
cap->oap->op_type = OP_DELETE;
+#ifdef FEAT_EVAL
+ set_op_var(OP_DELETE);
+#endif
cap->count1 = 1;
nv_dollar(cap);
finish_op = TRUE;
@@ -8219,8 +8225,33 @@ nv_operator(cap)
{
cap->oap->start = curwin->w_cursor;
cap->oap->op_type = op_type;
+#ifdef FEAT_EVAL
+ set_op_var(op_type);
+#endif
+ }
+}
+
+#ifdef FEAT_EVAL
+/*
+ * Set v:operator to the characters for "optype".
+ */
+ static void
+set_op_var(optype)
+ int optype;
+{
+ char_u opchars[3];
+
+ if (optype == OP_NOP)
+ set_vim_var_string(VV_OP, NULL, 0);
+ else
+ {
+ opchars[0] = get_op_char(optype);
+ opchars[1] = get_extra_op_char(optype);
+ opchars[2] = NUL;
+ set_vim_var_string(VV_OP, opchars, -1);
}
}
+#endif
/*
* Handle linewise operator "dd", "yy", etc.
diff --git a/src/version.c b/src/version.c
index f9ad029a7..c9508b969 100644
--- a/src/version.c
+++ b/src/version.c
@@ -667,6 +667,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 205,
+/**/
204,
/**/
203,
diff --git a/src/vim.h b/src/vim.h
index 05efc9a20..bfbfde06e 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -1688,7 +1688,8 @@ int vim_memcmp __ARGS((void *, void *, size_t));
#define VV_MOUSE_WIN 49
#define VV_MOUSE_LNUM 50
#define VV_MOUSE_COL 51
-#define VV_LEN 52 /* number of v: vars */
+#define VV_OP 52
+#define VV_LEN 53 /* number of v: vars */
#ifdef FEAT_CLIPBOARD