• Stars
    star
    828
  • Rank 55,086 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created about 13 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

File creation plugin for Sublime Text

AdvancedNewFile

Advanced file creation for Sublime Text.

Overview

This plugin allows for faster file creation within a project. Please see the Features section for more detailed information about advanced features.

Compatability Notes

Sublime Text 2 and 3

Version 1.7.0 is the final version that will be compatible with Sublime Text 2 and 3. Compatiability with these versions of Sublime Text are no longer planned to be maintained and will not receive future enhancements. If the latest features are needed, consider upgrading to Sublime Text 4.

Installation

Note with either method, you may need to restart Sublime Text 2 for the plugin to load.

Package Control

Installation through package control is recommended. It will handle updating your packages as they become available. To install, do the following.

  • In the Command Palette, enter Package Control: Install Package
  • Search for ANF to see the list of available commands

Manual

Clone or copy this repository into the packages directory. You will need to rename the folder to AdvancedNewFile if using this method. By default, the Package directory is located at:

  • OS X: ~/Library/Application Support/Sublime Text 2/Packages/
  • Windows: %APPDATA%/Sublime Text 2/Packages/
  • Linux: ~/.config/sublime-text-2/Packages/

or

  • OS X: ~/Library/Application Support/Sublime Text 3/Packages/
  • Windows: %APPDATA%/Sublime Text 3/Packages/
  • Linux: ~/.config/sublime-text-3/Packages/

Depending on your install on windows, the ST packages path may be %APPDATA%/Sublime Text 2/...

Usage

Simply bring up the AdvancedNewFile input through the appropriate key binding. Then, enter the path, along with the file name into the input field. Upon pressing enter, the file will be created. In addition, if the directories specified do not yet exists, they will also be created. For more advanced usage of this plugin, be sure to look at Advanced Path Usage. By default, the path to the file being created will be shown in the status bar as you enter the path information.

Default directory: The default directory is specified by the default_root setting. By default, it will be the top directory of the folders listed in the window. If this cannot be resolved, the home directory will be used. See Settings (default_root) for more information.

Commands with no Default Bindings

The plugin supports renaming and deleting files. However, these are not, by default bound to any key binding. For more information on the available commands, see the GitHub wiki page.

Adding Commands to Menu

The plugin does not contain any menu commands by default. To add them yourself, please see the GitHubwiki

Keymaps

If you have issues with keymaps, consider running FindKeyConflicts, also available through the package manager. Alternatively, set command logging to true by entering sublime.log_commands(True) in the Sublime Text console.

Windows

ctrl+alt+n: General keymap to create new files.

ctrl+shift+alt+n: In addition to creating the folders specified, new folders will also contain an __init__.py file.

OS X and Linux

The super keys for Linux and OS X are the Windows and command key respectively.

super+alt+n: General keymap to create new files.

shift+super+alt+n: In addition to creating the folders specified, new folders will also contain an __init__.py file.

Settings

Default settings can be seen by navigating to Preferences -> Packages Settings -> AdvancedNewFile - Default. To modify the default settings, navigate to Preferences -> Packages Settings -> AdvancedNewFile -> User.

alias:

A dictionary that contains a set of aliases tied to a directory. For more information, see Aliases

os_specific_alias:

A dictionary containing a set of aliases tied to a directory. These aliases will be platform specific. For more information, see Platform Specific Aliases

default_initial:

A string that will be automatically inserted into the new file creation input.

use_cursor_text:

A boolean value determining if text from a buffer, bound by quotes or a selected region, will be auto inserted into the new file generation input field. If multiple cursors are used, the first entry either contained in quotes, are a selected region, will be used.

show_files:

A boolean value determining if regular files should be included in the autocompletion list.

show_path:

A boolean value used to determine if the path of the file to be created should be displayed in the status bar.

default_root:

This value is used to determine the default root when using AdvancedNewFile. It must be one of the following values:

  • project_folder- The default path will be the folder specified by the 'default_folder_index' setting.
  • current - The default path will be the directory of the current active view.
  • home - The default path will be your home directory.
  • path - The default path will be defined by the setting default_path

If the current view's directory cannot be resolved, the top level folder in the window will be used. If the top level folder in the window cannot be resolved either, the home directory will be used.

default_path:

This path is used as the default if path has been specified for the setting default_root. This path should be absolute. If a relative path is specified, it will be relative to the AdvancedNewFile package directory.

default_folder_index:

An integer value representing a folder index to be used when "folder" is specified for "default_root". If an index outside of the range of existing folders is used, it will default to 0 (the top level folder).

alias_root:

This entry defines the root that will be used when resolving aliases defined as relative paths. For more information about valid entries, see default_root. Note that for path, alias_path will be specified.

alias_path:

This path is used as the default if path has been specified for the setting alias_root.

alias_folder_index:

An integer value representing the folder index to use when "folder" is specified for "alias_root". If an index outside of the range of the existing folders is used, it will default to 0.

ignore_case:

A boolean specifying if case should be ignored when building auto complete list.

auto_refresh_sidebar:

A boolean specifying if folders should automatically refresh and update the sidebar. In some builds, the sidebar does not refresh when contents of project folder are updated. This setting is required to refresh the sidebar in these circumstances. False by default.

completion_type:

A string specifying the type of auto completion to use. Valid values are "windows" or "nix".

complete_single_entry

A boolean setting specifying if a separator should be inserted when there is only one completion and completion type is "windows"

use_folder_name:

A boolean setting specifying if the folder name should be used or the name specified in the project. This setting only applies to ST3.

relative_from_current:

Boolean setting specifying if relative paths should be based on the current working directory.

default_extension:

String containing the default file extension. Note the extension is only applied if the specified path does not contain a dot (.) character.

folder_permissions:

String representing permissions to be applied to newly created folders. E.g. "777" -> RWX for user, group, and other.

file_permissions:

String representing permissions to be applied to newly created files. E.g. "777" -> RWX for user, group, and other.

rename_default:

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.

vcs_management:

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

file_templates:

An object containing information to use for templates when creating new files. The key values for this object should be a file extension. Files without extensions such as "Makefile" or ".bash_profile" use the full file name as the key. The value may either be a string of the content to be inserted or a list of paths. If a list of paths is specified, the name of the file will be displayed during selection. The paths must either be absolute, from the home directory of the user (~/), or relative to the Packages directory. These relative files should have the form "Packages/User/mytest.sublime-snippet". If a string is used, or the list contains a single entry, it will be automatically inserted into any newly created files.

shell_input:

Setting this value to true will allow you to escape characters as you normally would when using a shell. For example, given the input string "foo\ bar", false would result in a file named " bar" in the foo directory. With the value set to true, a file named "foo bar" would be created. In addition, setting this value to true will allow for curly brace expansion. Currently, only comma separated entries are supported.

append_extension_on_move:

Setting to control if the extension will be automatically applied to renamed files.

relative_fallback_index:

An integer value representing a folder index to be used when a relative path cannot be resolved from the current active view. If an index outside of the range of existing folders is used, it will default to 0 (the top level folder). If no folders exist as part of the project the home directory will be used.

append_extension_on_copy:

Setting to control if the extension will be automatically applied to copied files.

copy_default:

Same as rename_default, applied to copy command.

cut_to_file_default:

Same as rename_default, applied to cut to file command.

current_fallback_to_project:

If default_root is set to current, the project folder should be used as the default rather than the home directory.

warn_overwrite_on_move:

If a warning should be displayed when trying to overwrite an existing file using the move command.

new_file_default_root: Same as default_root for new file commands. In addition to the valid values listed for default_root, "default_root" will use the value for that setting.

rename_file_default_root: Same as default_root for rename file commands. In addition to the valid values listed for default_root, "default_root" will use the value for that setting.

copy_file_default_root: Same as default_root for copy file commands. In addition to the valid values listed for default_root, "default_root" will use the value for that setting.

empty_filename_action: On empty input of file name, execute an alternative action. Currently only implemented for the new file command, which will open a new unnamed file. Default value is false

cursor_before_extension: When specifying initial input, this boolean will place the cursor prior to the last occurring dot. Default value is False.

Project Specific Settings

All of the above settings can also be specified as part of the project specific settings. These values override any previous values set by higher level settings, with aliases being an exception. Alias settings will be merged with higher level configurations for alias. In addition, if the same alias exist for both default/user settings and project settings, the project setting will take precedence.

"settings": {
    "AdvancedNewFile": {
        "default_initial": "/project/specific/path"
    }
}

Features

init.py creation:

This plugin may optionally create __init__ in the created directories. Please reference Key Maps to see the default key bindings to do this.

Tab Autocompletion:

After typing in a partial path, simply press tab to autocomplete it. Continue to press tab to cycle through the options.

Advanced Path Usage

Home directory:

To begin at the home directory simply start with ~/ like you would in the shell.

Aliases:

You can create an alias to quickly navigate to a directory. Simply type in the alias followed by a colon. Then specify the path as you would normally. Note, in an event a specified alias conflicts with a predefined alias, the specified alias will take precedence.

Alias paths may be relative or absolute. If a relative path is specified, the alias_root setting will be used as the base. When specifying absolute paths, be sure to use the system specific style (e.g. Windows C:\\Users\\username\\Desktop, OS X and Linux /home/username/desktop/). In addition, you may specify an alias from the home directory by using ~/.

If an invalid alias is specified, an error pop up will be displayed when trying to create the file.

Sample aliases:

{
    "alias": {
        "Desktop": "~/Desktop/"
    }
}

To use the above alias, when specifying a new file enter Desktop:testDir/testFile, which would then create a file at <home_directory>/Desktop/testDir/testFile.

Platform Specific Aliases

You can also create aliases that are platform specific. These follow a similar set of rules as aliases. However, rather than specifying a string path to use, a dictionary is specified. This dictionary may contain the following keys: windows, linux, and osx. The path for this particular alias will be used based on the operating system in use. If the same alias is specified in both alias and os_specific_alias, the path in os_specific_alias will be used.

Sample OS Specific Aliases:

{
    "os_specific_alias": {
        "subl_packages": {
            "windows": "~\\AppData\\Roaming\\Sublime Text 2\\Packages",
            "linux": "~/.config/sublime-text-2/Packages",
            "osx": "~/Library/Application Support/Sublime Text 2/Packages"
        }
    }
}
Predefined Aliases
Top level folders in window

Top level folders can be specified by typing in the name of the folder followed by a colon. Then specify the path as you would normally.

Note

In Sublime Text 2, the name of the folder will be the actual name of the folder, not an arbitrary name specified in the project. However, due to an API update, folder names in Sublime Text 3 will match the Side Bar names. To achieve a similar behavior in Sublime Text 2, you can create Project Specific Settings for alias.

Current Working Directory

To specify the current working directory, simply type a colon, without any preceding text. Alternatively, set relative_from_current to true in your settings. Paths specified as relative paths will then begin from the current working directory.

Notes

Thanks to Dima Kukushkin (xobb1t) for the original work on this plugin. Also, thank you to facelessuser, and by extension biermeester and matthjes for the idea of platform specific settings. Additional thanks to kemayo for the work in identifying git executable.

Libraries Used

  • ushlex - Improved version of shlex, supporting unicode characters for Python 2.

Contributors

More Repositories

1

Spacegray

A Hyperminimal UI Theme for Sublime Text
JavaScript
7,188
star
2

LaTeXTools

LaTeX plugin for Sublime Text
Python
2,007
star
3

Origami

Split the window however you like! Create new panes, delete panes, move and clone views from pane to pane.
Python
1,208
star
4

CTags

CTags support for Sublime Text
Python
987
star
5

TrailingSpaces

Highlight trailing spaces and delete them in a flash.
Python
897
star
6

CoffeeScript

Syntax highlighting and checking, commands, shortcuts, snippets, watched compilation and more.
CoffeeScript
439
star
7

PackageDev

Tools to ease the creation of snippets, syntax definitions, etc. for Sublime Text.
Python
436
star
8

VintageEx

An implementation of Vim's command-line mode for Sublime Text 2
Python
381
star
9

PowerShell

Support for the MS PowerShell programming language.
PowerShell
313
star
10

Helium

Let Sublime Text talk with Jupyter.
Python
236
star
11

ColdFusion

ColdFusion Sublime Text Package
Python
197
star
12

VBScript

VBScript package for Sublime Text
Python
185
star
13

WordHighlight

Highlight all copies of the currently selected word.
Python
180
star
14

PhpDoc

PhpDoc support package.
JavaScript
165
star
15

Terraform

Terraform (HCL) configuration file syntax highlighting for Sublime Text
HCL
163
star
16

RSpec

Sublime Text 2 / 3 plugin for RSpec BDD Framework
Python
124
star
17

InsertNums

Sublime Text plugin for inserting sequences. Supporting alphanumerics and hex, with bitwise operations!
Python
123
star
18

UnitTesting

Testing Sublime Text Packages
Python
111
star
19

IndentGuides

Draw vertical guides to easily visualize indent depth.
Python
106
star
20

Mote

SFTP Remote Editing for Sublime Text 2
Python
105
star
21

Pywin32

Pywin32 support for sublime (win32api etc)
Python
81
star
22

ElasticTabstops

Tab characters automatically adjust to keep adjacent lines aligned.
Python
67
star
23

PhpBeautifier

Pear Php_beautifier plugin for Sublime Text 2
Python
66
star
24

SaneSnippets

Sublime Text snippets optimized for humans, not robots
Python
59
star
25

LegacyColorSchemes

Color schemes that were part of Sublime Text 2 and older builds of Sublime Text 3
52
star
26

sublime_lib

Utility library for frequently used functionality in Sublime Text and convenience functions or classes
Python
52
star
27

Theme-DAneo

A theme for Sublime Text 3.2+ inspired by the popular DA UI
Python
51
star
28

Sass

Sass and SCSS syntax for Sublime Text
SCSS
50
star
29

material-theme

Material Theme, a theme for Sublime Text 3, made by Mattia Astorino
Python
44
star
30

GenerateUUID

Generate UUID for Sublime Text
Python
42
star
31

NSIS

Sublime Text plugin for the Nullsoft Scriptable Install System
Shell
40
star
32

WinMerge

Plugin that enables comparison of the last 2 activated buffers (even in different windows) using WinDiff (Windows only).
Python
37
star
33

InactivePanes

Sublime Text plugin that slightly dims (or grays) inactive panes in your group view
Python
32
star
34

SublimeHg

Use Mercurial from Sublime Text.
Python
30
star
35

QML

QML support for Sublime Text and Sublime Merge
QML
28
star
36

StatusBarFileSize

Show the file size in the Sublime Text status bar
Python
27
star
37

TailwindCSS

Tailswind CSS syntax for Sublime Text
CSS
24
star
38

MouseEventListener

Adds on_pre_click and on_post_click callbacks to Sublime Text's plugin API.
JavaScript
24
star
39

Mojolicious

Mojolicious package for the Perl Web Dev Framework for Sublime Text 2
JavaScript
22
star
40

Modelines

Vim-like modelines for Sublime Text.
Python
21
star
41

NaturalDocs

NaturalDocs package for SublimeText 2
JavaScript
21
star
42

ExtractSublimePackage

Extract .sublime-package files to the Sublime Text Packages folder.
Python
20
star
43

RevertFontSize

Sublime Text plugin to quickly revert to a preferred font size
Python
20
star
44

LegacyTheme

Sublime Text 2's default theme with retina graphics
19
star
45

YamlPipelines

Sublime Syntax Definitions for YAML CI/CD pipelines like GitHub Actions, AzureDevops, Kong API Gateway, Gitlab CICD, Bitbucket, Drone CI etc.
Python
18
star
46

KnowledgeBase

Sublime Text Knowledge Base
Python
18
star
47

ScrollOffset

Python
18
star
48

UberSelection

Commands to extend the functionality of Sublime Text's multiselection.
Python
17
star
49

PythonOpenModule

Open python modules on sys.path and open folders in window
Python
16
star
50

PowershellUtils

Run powershell commands from within Sublime Text.
Python
16
star
51

Rake

Sublime Text 2 plugin for Ruby Rake
Python
15
star
52

JumpTo

Sublime Text plugin to move (multiple) cursors
Python
13
star
53

SwitchWindow

A plugin to quickly switch between Sublime Text windows via Command Palette
Python
12
star
54

ScopeNamingGuidelines

Collection of documents for scope naming guidelines in Sublime Text syntax definitions
12
star
55

AutoSelect

Sticky Selection
Python
12
star
56

SublimeCMD

Simple command processor for Sublime Text.
Python
12
star
57

syntax-test-action

Github Action to run syntax tests
Shell
12
star
58

OpenDefaultApplication

Sublime Text plugin to open files in the system default application
Python
11
star
59

Terminal

Launch terminals from the current file or the root project folder
Python
11
star
60

Sublime-Snipt

Sublime Text 2 plugin that will sync with snipt.net
Python
10
star
61

sublimetext.github.io

GitHub Organization for Open-Source Sublime Text Package Development
9
star
62

AutoProjects

A Sublime Text plugin to open folders as projects
Python
9
star
63

PackageTesting

Minimal testing framework for Sublime Text packages. (beta)
Python
8
star
64

WslBuild

A Sublime Text package to create build systems running in WSL2
Python
7
star
65

Astro

Astro syntax for Sublime Text
Astro
7
star
66

TJ3-syntax-sublimetext2

Taskjuggler 3 syntax and code snippets for Sublime Text 2
7
star
67

Mustache

Mustache syntax and snippets for Sublime Text
Mustache
6
star
68

Less

Less syntax for Sublime Text
Less
6
star
69

LINQPad

Syntax highlighting and build system for LINQPad scripts
5
star
70

AlpineJS

AlpineJS syntax for Sublime Text
PHP
4
star
71

Ceedling

Sublime Text plugin for Ceedling C unit testing framework
Python
4
star
72

Gaelyk

Gaelyk Sublime Text Package
3
star
73

GoToEndOfLineOrScope

Sublime Text plugin to bind a key (for example the end key) to move/extend the cursor/selection(s) to the end of the line, or to before the specified scope (i.e. a comment) at the end of the line
Python
3
star
74

RichTextFormat

Syntax definition for RTF files in Sublime Text 3
2
star
75

wbond-packages

Packages created, and (mostly) managed by Will Bond
1
star
76

OpenFileInCurrentFolder

Allows opening of files in the same folder as the active view
Python
1
star