Skip to content

Instantly share code, notes, and snippets.

@presuku
Last active June 5, 2017 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save presuku/dc6bb11dfdb83535d82b1b6d7310e5bf to your computer and use it in GitHub Desktop.
Save presuku/dc6bb11dfdb83535d82b1b6d7310e5bf to your computer and use it in GitHub Desktop.
Add i_CTRL-R state to mode(1) for after [ctrl_v_mode.patch](https://gist.github.com/presuku/fa7f351e792a9e74bfbd61684f0139ab) #vim
diff --git a/src/edit.c b/src/edit.c
index d7486a31d..a7c17515e 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -1103,7 +1103,9 @@ doESCkey:
break;
case Ctrl_R: /* insert the contents of a register */
+ ctrl_r_mode = 1;
ins_reg();
+ ctrl_r_mode = 0;
auto_format(FALSE, TRUE);
inserted_space = FALSE;
break;
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 72a14e129..bb6c386d2 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -7884,6 +7884,8 @@ f_mode(typval_T *argvars, typval_T *rettv)
}
if (ctrl_v_mode == 1)
buf[1] = 'V';
+ if (ctrl_r_mode == 1)
+ buf[1] = 'r';
}
else if ((State & CMDLINE) || exmode_active)
{
@@ -7894,6 +7896,8 @@ f_mode(typval_T *argvars, typval_T *rettv)
buf[1] = 'e';
if (ctrl_v_mode == 1)
buf[1] = 'V';
+ if (ctrl_r_mode == 1)
+ buf[1] = 'r';
}
else
{
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 8bcaad575..cf5149e76 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -1483,6 +1483,7 @@ getcmdline(
goto returncmd; /* back to cmd mode */
case Ctrl_R: /* insert register */
+ ctrl_r_mode = 1;
#ifdef USE_ON_FLY_SCROLL
dont_scroll = TRUE; /* disallow scrolling here */
#endif
@@ -1527,6 +1528,7 @@ getcmdline(
{
gotesc = TRUE; /* will free ccline.cmdbuff after
putting it in history */
+ ctrl_r_mode = 0;
goto returncmd; /* back to cmd mode */
}
#endif
@@ -1543,6 +1545,7 @@ getcmdline(
#endif
}
redrawcmd();
+ ctrl_r_mode = 0;
goto cmdline_changed;
case Ctrl_D:
diff --git a/src/globals.h b/src/globals.h
index 344d0776a..ed7e08a2f 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -986,6 +986,8 @@ EXTERN int ctrl_x_mode INIT(= 0); /* Which Ctrl-X mode are we in? */
EXTERN int ctrl_v_mode INIT(= 0); /* Which Ctrl-V mode are we in? */
+EXTERN int ctrl_r_mode INIT(= 0); /* Which Ctrl-R mode are we in? */
+
EXTERN int no_abbr INIT(= TRUE); /* TRUE when no abbreviations loaded */
#ifdef USE_EXE_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment