diff options
author | HiPhish <hiphish@Aleksandars-iMac.local> | 2015-08-24 12:58:28 +0200 |
---|---|---|
committer | HiPhish <hiphish@Aleksandars-iMac.local> | 2016-04-20 12:52:31 +0200 |
commit | ec71d87b8140ae097158f7e219b26701aed8158e (patch) | |
tree | ed9420d1d76c3b2ece7be3f8d89333604aa049f7 /runtime | |
parent | a7a0bf54e3f339f7bf1f97dee44546cdcd926b1d (diff) | |
download | rneovim-ec71d87b8140ae097158f7e219b26701aed8158e.tar.gz rneovim-ec71d87b8140ae097158f7e219b26701aed8158e.tar.bz2 rneovim-ec71d87b8140ae097158f7e219b26701aed8158e.zip |
Implement tab-local working directory feature.
New ex commands: 'tcd', 'tchdir'
Changed Vimscript functions: 'haslocaldir', 'getcwd'
The ex-commands ':tcd' and ':tchdir' are the tab-local equivalents of
':lcd' and ':lchdir'. There are no new Vimscript functions introduced,
instead the functions 'haslocaldir' and 'getcwd' take in optional
arguments. See the documentation for details
Since there is now different levels of local directory a simple boolean
at source level is no longer sufficient; a new enumeration type is used
for the scope-level from now on.
The documentation has been accommodated for these new commands and
functional tests have been written to test the feature.
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/editing.txt | 59 | ||||
-rw-r--r-- | runtime/doc/eval.txt | 38 |
2 files changed, 75 insertions, 22 deletions
diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt index d2b9374143..ebf524fdbb 100644 --- a/runtime/doc/editing.txt +++ b/runtime/doc/editing.txt @@ -1216,12 +1216,20 @@ use has("browsefilter"): > ============================================================================== 7. The current directory *current-directory* -You may use the |:cd| and |:lcd| commands to change to another directory, so -you will not have to type that directory name in front of the file names. It -also makes a difference for executing external commands, e.g. ":!ls". +You may use the |:cd|, |:tcd| and |:lcd| commands to change to another +directory, so you will not have to type that directory name in front of the +file names. It also makes a difference for executing external commands, e.g. +":!ls". -Changing directory fails when the current buffer is modified, the '.' flag is -present in 'cpoptions' and "!" is not used in the command. +There are three levels of working directories: global, tab and window. The +local working directory of the current window takes precedence over the local +working directory of the tab, which in turn takes precedence over the global +working directory. If a local working directory, tab or window, does not +exist, the next one in the hierarchy applies. + +All commands for changing the working directory can be suffixed with an +exclamation mark (e.g. |:cd!|). This is for compatibility with Vim and will be +ignored by Neovim. *:cd* *E747* *E472* :cd[!] On non-Unix systems: Print the current directory @@ -1246,29 +1254,50 @@ present in 'cpoptions' and "!" is not used in the command. *:chd* *:chdir* :chd[ir][!] [path] Same as |:cd|. + *:tc* *:tcd* *E5000* *E5001* *E5002* +:tc[d][!] {path} Like |:cd|, but set the current directory for the + current tab. The current directory for other tabs + or the local directory of windows in this tab is not + changed, except for the current window. + + *:tcd-* +:tcd[!] - Change to the previous current directory (before the + previous ":tcd {path}" command). + + *:tch* *:tchdir* +:tch[dir][!] Same as |:tcd|. + *:lc* *:lcd* :lc[d][!] {path} Like |:cd|, but only set the current directory for the current window. The current directory for other - windows is not changed. + windows or any tabs is not changed. *:lch* *:lchdir* :lch[dir][!] Same as |:lcd|. + *:lcd-* +:lcd[!] - Change to the previous current directory (before the + previous ":tcd {path}" command). + *:pw* *:pwd* *E187* :pw[d] Print the current directory name. Also see |getcwd()|. -So long as no |:lcd| command has been used, all windows share the same current -directory. Using a command to jump to another window doesn't change anything -for the current directory. +So long as no |:tcd| or |:lcd| command has been used, all windows share the +same current directory. Using a command to jump to another window doesn't +change anything for the current directory. When a |:lcd| command has been used for a window, the specified directory becomes the current directory for that window. Windows where the |:lcd| -command has not been used stick to the global current directory. When jumping -to another window the current directory will become the last specified local -current directory. If none was specified, the global current directory is -used. -When a |:cd| command is used, the current window will lose his local current -directory and will use the global current directory from now on. +command has not been used stick to the tab- or global current directory. When +jumping to another window the current directory will become the last specified +local current directory. If none was specified, the tab- or global current +directory is used. +When changing tabs the same behaviour applies. If the current tab has no +local working directory the global working directory is used. When a |:cd| +command is used, the current window and tab will lose their local current +directories and will use the global current directory from now on. When a +|:tcd| command is used, only the current window will lose its local working +directory. After using |:cd| the full path name will be used for reading and writing files. On some networked file systems this may cause problems. The result of diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 476ab71461..3e1281a021 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1886,7 +1886,7 @@ getcmdpos() Number return cursor position in command-line getcmdtype() String return current command-line type getcmdwintype() String return current command-line window type getcurpos() List position of the cursor -getcwd() String the current working directory +getcwd( [{scope}]) String the current working directory getfontname( [{name}]) String name of font being used getfperm( {fname}) String file permissions of file {fname} getfsize( {fname}) Number size in bytes of file {fname} @@ -3559,9 +3559,22 @@ getcurpos() Get the position of the cursor. This is like getpos('.'), but MoveTheCursorAround call setpos('.', save_cursor) < - *getcwd()* -getcwd() The result is a String, which is the name of the current - working directory. +getcwd([{window}[, {tab}]]) *getcwd()* + With no argument the result is a String, which is the name of the + current effective working directory. If an arguments are provided for a + window or a tabpage the working directory of that scope is returned. + + Tabs and windows are identified using their respective number. If a + number is 0 the current tab or window is implied. If one is not given + it defaults to 0. Thus + + getcwd() + getcwd(0) + getcwd(0, 0) + + are all equal. If {window} is -1 it will be ignored and only the tab + will be looked at. + getfsize({fname}) *getfsize()* The result is a Number, which is the size in bytes of the @@ -3896,9 +3909,20 @@ has_key({dict}, {key}) *has_key()* The result is a Number, which is 1 if |Dictionary| {dict} has an entry with key {key}. Zero otherwise. -haslocaldir() *haslocaldir()* - The result is a Number, which is 1 when the current - window has set a local path via |:lcd|, and 0 otherwise. +haslocaldir([{window}[, {tab}]]) *haslocaldir()* + The result is a Number, which is 1 when the specified tabpage or window + has a local path set via |:lcd| or |:tcd|, and 0 otherwise. + + Tabs and windows are identified using their respective number. If a + number is 0 the current tab or window is implied. If one is not given + it defaults to 0. Thus + + haslocaldir() + haslocaldir(0) + haslocaldir(0, 0) + + are all equal. If {window} is -1 it will be ignored and only the tab + will be looked at. hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()* The result is a Number, which is 1 if there is a mapping that |