updated for version 7.0182
diff --git a/src/buffer.c b/src/buffer.c
index 1190117..677215d 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1806,10 +1806,11 @@
     if (buf == curbuf)
 	return OK;
 
-#ifdef FEAT_CMDWIN
-    if (cmdwin_type != 0)
+    if (editing_cmdline())
+    {
+	editing_cmdline_msg();
 	return FAIL;
-#endif
+    }
 
     /* altfpos may be changed by getfile(), get it now */
     if (lnum == 0)
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index e15c6c5..fe9cd6b 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -2026,7 +2026,17 @@
 	}
 	else if (ea.addr_count != 0)
 	{
-	    if (ea.line2 < 0 || ea.line2 > curbuf->b_ml.ml_line_count)
+	    if (ea.line2 > curbuf->b_ml.ml_line_count)
+	    {
+		/* With '-' in 'cpoptions' a line number past the file is an
+		 * error, otherwise put it at the end of the file. */
+		if (vim_strchr(p_cpo, CPO_MINUS) != NULL)
+		    ea.line2 = -1;
+		else
+		    ea.line2 = curbuf->b_ml.ml_line_count;
+	    }
+
+	    if (ea.line2 < 0)
 		errormsg = (char_u *)_(e_invrange);
 	    else
 	    {
@@ -2126,18 +2136,22 @@
 	    errormsg = (char_u *)_(e_modifiable);
 	    goto doend;
 	}
-#ifdef FEAT_CMDWIN
-	if (cmdwin_type != 0 && !(ea.argt & CMDWIN)
+
+	if (editing_cmdline() && !(ea.argt & CMDWIN)
 # ifdef FEAT_USR_CMDS
 		&& !USER_CMDIDX(ea.cmdidx)
 # endif
 	   )
 	{
-	    /* Command not allowed in cmdline window. */
-	    errormsg = (char_u *)_(e_cmdwin);
+	    /* Command not allowed when editing the command line. */
+#ifdef FEAT_CMDWIN
+	    if (cmdwin_type != 0)
+		errormsg = (char_u *)_(e_cmdwin);
+	    else
+#endif
+		errormsg = (char_u *)_(e_secure);
 	    goto doend;
 	}
-#endif
 
 	if (!ni && !(ea.argt & RANGE) && ea.addr_count > 0)
 	{
@@ -2977,12 +2991,9 @@
     int			forceit = FALSE;
     int			usefilter = FALSE;  /* filter instead of file name */
 
+    ExpandInit(xp);
     xp->xp_pattern = buff;
     xp->xp_context = EXPAND_COMMANDS;	/* Default until we get past command */
-    xp->xp_backslash = XP_BS_NONE;
-#if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL)
-    xp->xp_arg = NULL;
-#endif
     ea.argt = 0;
 
 /*
@@ -3254,6 +3265,11 @@
 	if (bow != NULL && in_quote)
 	    xp->xp_pattern = bow;
 	xp->xp_context = EXPAND_FILES;
+#ifndef BACKSLASH_IN_FILENAME
+	/* For a shell command more chars need to be escaped. */
+	if (usefilter || ea.cmdidx == CMD_bang)
+	    xp->xp_shell = TRUE;
+#endif
 
 	/* Check for environment variable */
 	if (*xp->xp_pattern == '$'
@@ -4189,16 +4205,16 @@
 
 	/* For a shell command a '!' must be escaped. */
 	if ((eap->usefilter || eap->cmdidx == CMD_bang)
-			      && vim_strpbrk(repl, (char_u *)"!&;()") != NULL)
+			    && vim_strpbrk(repl, (char_u *)"!&;()<>") != NULL)
 	{
 	    char_u	*l;
 
-	    l = vim_strsave_escaped(repl, (char_u *)"!&;()");
+	    l = vim_strsave_escaped(repl, (char_u *)"!&;()<>");
 	    if (l != NULL)
 	    {
 		vim_free(repl);
 		repl = l;
-		/* For a sh-like shell escape it another time. */
+		/* For a sh-like shell escape "!" another time. */
 		if (strstr((char *)p_sh, "sh") != NULL)
 		{
 		    l = vim_strsave_escaped(repl, (char_u *)"!");
@@ -6017,6 +6033,12 @@
 	return;
     }
 #endif
+    /* Don't quit while editing the command line. */
+    if (editing_cmdline())
+    {
+	editing_cmdline_msg();
+	return;
+    }
 
 #ifdef FEAT_NETBEANS_INTG
     netbeansForcedQuit = eap->forceit;
@@ -6079,6 +6101,14 @@
 	return;
     }
 # endif
+
+    /* Don't quit while editing the command line. */
+    if (editing_cmdline())
+    {
+	editing_cmdline_msg();
+	return;
+    }
+
     exiting = TRUE;
     if (eap->forceit || !check_changed_any(FALSE))
 	getout(0);
@@ -6098,7 +6128,8 @@
 	cmdwin_result = K_IGNORE;
     else
 # endif
-	ex_win_close(eap, curwin);
+	if (!editing_cmdline())
+	    ex_win_close(eap, curwin);
 }
 
     static void
@@ -6257,6 +6288,12 @@
 	return;
     }
 #endif
+    /* Don't quit while editing the command line. */
+    if (editing_cmdline())
+    {
+	editing_cmdline_msg();
+	return;
+    }
 
     /*
      * if more files or windows we won't exit
@@ -6369,10 +6406,9 @@
     exarg_T	ea;
     int		save_msg_scroll = msg_scroll;
 
-# ifdef FEAT_CMDWIN
-    if (cmdwin_type != 0)
+    /* Postpone this while editing the command line. */
+    if (editing_cmdline())
 	return;
-# endif
 
     /* Check whether the current buffer is changed. If so, we will need
      * to split the current window or data could be lost.
diff --git a/src/normal.c b/src/normal.c
index b0262b2..12ede73 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -788,15 +788,14 @@
 	clearopbeep(oap);
 	goto normal_end;
     }
-#ifdef FEAT_CMDWIN
-    if (cmdwin_type != 0 && (nv_cmds[idx].cmd_flags & NV_NCW))
+
+    if (editing_cmdline() && (nv_cmds[idx].cmd_flags & NV_NCW))
     {
-	/* This command is not allowed in the cmdline window: beep. */
+	/* This command is not allowed wile editing a ccmdline: beep. */
 	clearopbeep(oap);
-	EMSG(_(e_cmdwin));
+	editing_cmdline_msg();
 	goto normal_end;
     }
-#endif
 
 #ifdef FEAT_VISUAL
     /*
@@ -3640,6 +3639,7 @@
 	K_RIGHTMOUSE, K_RIGHTDRAG, K_RIGHTRELEASE,
 	K_MOUSEDOWN, K_MOUSEUP,
 	K_X1MOUSE, K_X1DRAG, K_X1RELEASE, K_X2MOUSE, K_X2DRAG, K_X2RELEASE,
+	K_CURSORHOLD,
 	0
     };
 #endif
@@ -5741,13 +5741,12 @@
 {
     char_u	*ptr;
 
-#ifdef FEAT_CMDWIN
-    if (cmdwin_type != 0)
+    if (editing_cmdline())
     {
 	clearopbeep(cap->oap);
+	editing_cmdline_msg();
 	return;
     }
-#endif
 
     ptr = grab_file_name(cap->count1);
 
@@ -7802,13 +7801,13 @@
 
     /* "gQ": improved Ex mode */
     case 'Q':
-#ifdef FEAT_CMDWIN
-	if (cmdwin_type != 0)
+	if (editing_cmdline())
 	{
 	    clearopbeep(cap->oap);
+	    editing_cmdline_msg();
 	    break;
 	}
-#endif
+
 	if (!checkclearopq(oap))
 	    do_exmode(TRUE);
 	break;
diff --git a/src/os_unix.c b/src/os_unix.c
index faf2847..afc68ff 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -4852,7 +4852,7 @@
 # define SEEK_END 2
 #endif
 
-#define SHELL_SPECIAL (char_u *)"\t \"&';<>[\\]|"
+#define SHELL_SPECIAL (char_u *)"\t \"&';<>\\|"
 
 /* ARGSUSED */
     int
diff --git a/src/proto/ex_getln.pro b/src/proto/ex_getln.pro
index fe2752b..3b11a38 100644
--- a/src/proto/ex_getln.pro
+++ b/src/proto/ex_getln.pro
@@ -1,6 +1,8 @@
 /* ex_getln.c */
 char_u *getcmdline __ARGS((int firstc, long count, int indent));
 char_u *getcmdline_prompt __ARGS((int firstc, char_u *prompt, int attr, int xp_context, char_u *xp_arg));
+int editing_cmdline __ARGS((void));
+void editing_cmdline_msg __ARGS((void));
 char_u *getexline __ARGS((int c, void *dummy, int indent));
 char_u *getexmodeline __ARGS((int promptc, void *dummy, int indent));
 int cmdline_overstrike __ARGS((void));
diff --git a/src/vim.h b/src/vim.h
index 9fc38f5..bc0b334 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -324,6 +324,7 @@
 # else
 #  define PATH_ESC_CHARS ((char_u *)" \t*?[{`$\\%#'\"|")
 # endif
+# define SHELL_ESC_CHARS ((char_u *)" \t*?[{`$\\%#'\"|<>();&!")
 #endif
 
 #define NUMBUFLEN 30	    /* length of a buffer to store a number in ASCII */
diff --git a/src/window.c b/src/window.c
index 7d50180..680c320 100644
--- a/src/window.c
+++ b/src/window.c
@@ -2717,13 +2717,13 @@
 win_goto(wp)
     win_T	*wp;
 {
-#ifdef FEAT_CMDWIN
-    if (cmdwin_type != 0)
+    if (editing_cmdline())
     {
 	beep_flush();
+	editing_cmdline_msg();
 	return;
     }
-#endif
+
 #ifdef FEAT_VISUAL
     if (wp->w_buffer != curbuf)
 	reset_VIsual_and_resel();