Skip to content

Commit b2d2a51

Browse files
committed
Add new special value <filedirectory> for rename default.
1 parent 0b4ef4f commit b2d2a51

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

AdvancedNewFile.sublime-settings

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@
108108

109109
// Default input for renaming a file. Special value <filename> will be replaced
110110
// with the current file name. Special value <filepath> will be replaced with
111-
// the complete filepath (i.e. it already includes the filename).
111+
// the complete filepath, including the filename. Special value <filedirectory>
112+
// will be replaced with the filepath, not including the filename. Note that a
113+
// colon as the default will resolve to the same path as <filedirectory>, if the
114+
// file exists on disk.
112115
"rename_default": "",
113116

114117
// Setting to control if VCS management is used when moving and removing files.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ String representing permissions to be applied to newly created files. E.g. "777"
150150

151151
`rename_default`:
152152

153-
Default input for renaming a file. Special value `<filename>` will be replaced with the current file name. Special value `<filepath>` will be replaced with the absolute path of the current file.
153+
Default input for renaming a file. Special value `<filename>` will be replaced with the current file name. Special value `<filepath>` will be replaced with the complete filepath, including the filename. Special value `<filedirectory>` will be replaced with the filepath, not including the filename. Note that a colon as the default will resolve to the same path as `<filedirectory>`, if the file exists on disk.
154154

155155
`vcs_management`:
156156

advanced_new_file/commands/move_file_command.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ def run(self, is_python=False, initial_path=None, rename_file=None):
2121
path = self.settings.get(RENAME_DEFAULT_SETTING)
2222
current_file = self.view.file_name()
2323
if current_file:
24+
directory, current_file_name = os.path.split(current_file)
2425
path = path.replace("<filepath>", current_file)
25-
current_file_name = os.path.basename(self.view.file_name())
26+
path = path.replace("<filedirectory>", directory + os.sep)
2627
else:
2728
current_file_name = ""
2829

0 commit comments

Comments
 (0)