Index: runtime/doc/version7.txt
===================================================================
--- runtime/doc/version7.txt	(revision 242)
+++ runtime/doc/version7.txt	(working copy)
@@ -818,6 +818,7 @@
 |bufnr()|		takes an extra argument: create buffer
 |byteidx()|		index of a character (Ilya Sher)
 |call()|		call a function with List as arguments
+|cdcmd()|		check if current window used |:lcd|
 |changenr()|		number of current change
 |complete()|		set matches for Insert mode completion
 |complete_add()|	add match for 'completefunc'
Index: runtime/doc/todo.txt
===================================================================
--- runtime/doc/todo.txt	(revision 242)
+++ runtime/doc/todo.txt	(working copy)
@@ -606,9 +606,6 @@
 8   When redirecting and using ":silent" the current column for displaying and
     redirection can be different.  Use a separate variable to hold the column
     for redirection.
-7   There is no way to change directory and go back without changing the local
-    and/or global directory.  Add a way to find out if the current window uses
-    a local directory.  Add cdcmd() that returns ":cd" or ":lcd"?
 7   The messages for "vim --help" and "vim --version" don't use
     'termencoding'.
 8   When 'scrollbind' is set, a window won't scroll horizontally if the cursor
Index: runtime/doc/usr_41.txt
===================================================================
--- runtime/doc/usr_41.txt	(revision 242)
+++ runtime/doc/usr_41.txt	(working copy)
@@ -703,6 +703,7 @@
 	isdirectory()		check if a directory exists
 	getfsize()		get the size of a file
 	getcwd()		get the current working directory
+	cdcmd()			check if current window used |:lcd|
 	tempname()		get the name of a temporary file
 	mkdir()			create a new directory
 	delete()		delete a file
Index: runtime/doc/eval.txt
===================================================================
--- runtime/doc/eval.txt	(revision 242)
+++ runtime/doc/eval.txt	(working copy)
@@ -1542,6 +1542,7 @@
 byteidx( {expr}, {nr})		Number	byte index of {nr}'th char in {expr}
 call( {func}, {arglist} [, {dict}])
 				any	call {func} with arguments {arglist}
+cdcmd()				String	":lcd" if local dir, ":cd" otherwise
 changenr()			Number  current change number
 char2nr( {expr})		Number	ASCII value of first char in {expr}
 cindent( {lnum})		Number	C indent for line {lnum}
@@ -1970,6 +1971,10 @@
 		{dict} is for functions with the "dict" attribute.  It will be
 		used to set the local variable "self". |Dictionary-function|
 
+cdcmd()							*cdcmd()*
+		The result is a String, which is ':lcd' when the current
+                window has set a local path via |:lcd|, and ':cd' otherwise.
+
 changenr()						*changenr()*
 		Return the number of the most recent change.  This is the same
 		number as what is displayed with |:undolist| and can be used
Index: src/eval.c
===================================================================
--- src/eval.c	(revision 242)
+++ src/eval.c	(working copy)
@@ -472,6 +472,7 @@
 static void f_byte2line __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_byteidx __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_call __ARGS((typval_T *argvars, typval_T *rettv));
+static void f_cdcmd __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_changenr __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_char2nr __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_cindent __ARGS((typval_T *argvars, typval_T *rettv));
@@ -7039,6 +7040,7 @@
     {"byte2line",	1, 1, f_byte2line},
     {"byteidx",		2, 2, f_byteidx},
     {"call",		2, 3, f_call},
+    {"cdcmd",		0, 0, f_cdcmd},
     {"changenr",	0, 0, f_changenr},
     {"char2nr",		1, 1, f_char2nr},
     {"cindent",		1, 1, f_cindent},
@@ -8185,6 +8187,18 @@
 }
 
 /*
+ * "cdcmd()" function
+ */
+    static void
+f_cdcmd(argvars, rettv)
+    typval_T	*argvars;
+    typval_T	*rettv;
+{
+    rettv->vval.v_string = vim_strsave((char_u *)(curwin->w_localdir == NULL ? ":cd" : ":lcd"));
+    rettv->v_type = VAR_STRING;
+}
+
+/*
  * "changenr()" function
  */
 /*ARGSUSED*/
