ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Add​To​File

by nchauhan890 ST3

Sublime Text 3 plugin which allows for a selection to be instantly added to an open file

Details

Installs

  • Total 3K
  • Win 2K
  • Mac 306
  • Linux 300
Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1 Sep 30 Sep 29 Sep 28 Sep 27 Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9 Sep 8 Sep 7 Sep 6 Sep 5 Sep 4 Sep 3 Sep 2 Sep 1 Aug 31 Aug 30 Aug 29 Aug 28 Aug 27 Aug 26 Aug 25
Windows 0 1 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 1 3 0 0 0 1 1 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 1 0 0
Mac 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
Linux 0 3 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

AddToFile

Sublime Text 3 plugin which allows for a selection to be instantly added to an open file

Usage

When run, a panel appears containing a list of currently open files (excluding the current file). The content inside the selection will be copied to the end of the file selected from the panel. Note that the command will not be invoked if the selection is empty.

Demonstration

demo-1 Demonstration with standard settings

demo-2 Demonstration with file previews set to true and file paths set to true

demo-3 Demonstration with popup setting set to true

Configuration

Edit the AddToFile.sublime-settings to configure this plugin. Open through Preferences --> Package Settings --> AddToFile --> Settings - User or the command palette

Setting Description
suggest_new_file Add an option to create a new file inside the file selection panel. Defaults to true.
add_to_single_view Automatically select the view in the file selection panel if there is only one view in the list. Defaults to false. [1]
show_status_message Show a message in the status bar when text is copied. Defaults to true
show_file_path Show the full file path instead of the file name in the file selection panel to help distinguish files with the same name in different directories. Defaults to false. [2]
status_message Set the message to appear in the status bar. Defaults to Copied to {name}. [3]
keep_focus Keep the focus on the source file when copying rather than switching to the destination file's view. Defaults to true.
show_preview Show a 3-line file preview in the file selection panel. Defaults to false.
scroll_view Scroll the view to where the text was copied. Defaults to true. [4]
show_popup Show a popup at the cursor instead of a selection panel. Defaults to false. [5]
auto_smart Show a smart preview of files open in the file selection panel. Defaults to false. [6]

1: This will not work if add_to_suggest_new_file is set to true as this adds another element to the file list. Even if there is no other view open and New File is the only item in the list, the panel will still open to ensure that a new file isn't accidentally created.

2: If there are two files called AddToFile.py in different directories, the file selection panel will display AddToFile.py twice if this setting is set to false. However, the order that appears in the selection panel is the order of the view tabs from left to right which means the files could be distinguished by looking at which one's view tab is furthest left/right.

3: Can include {name}, {path}, {dir}, {sourcename}, {sourcepath} and {sourcedir} which will be replaced with their corresponding values:

Segment Description
name file name
path the path to the file including the file
dir the path to the file excluding the file
sourcename source file name
sourcepath the path to the source file including the file
sourcedir the path to the source file excluding the file

4: keep_focus must be set to false to allow the view to switch.

5: File previews will not be shown and show_preview setting will be ignored

6: Usually, file names are shown on their own, however, if there are multiple files with the same name, a folder will be shown in brackets: the folder name is the first folder in the 2 conflicting file paths whose name is different. E.g. (GitHub) AddToFile.py and (Documents) AddToFile.py would be shown for 2 files in directories GitHub/AddToFile/AddToFile.py and Documents/AddToFile/AddToFile.py

Command Palette

Open the command palette and type AddToFile to show available commands:

Command Description
AddToFile: Add to... Run AddToFile command
Preferences: AddToFile Settings Edit AddToFile user settings
Preferences: AddToFile Key Bindings Edit AddToFile key binding
AddToFile: Add to New File Run AddToFile command, but explicitly specifying to create a new file
AddToFile: Change preview lines Set the lines to preview to the 3 lines starting from the first cursor point (Limited to the view's individual settings so will reset on the closing of the view)
AddToFile: Get preview lines Scroll the view to to show the lines which will be previewed
AddToFile: Add to... (smart) Run AddToFile command, but the version that would be run if auto_smart in settings was enabled

Context Menu

The following commands are available via the view's context menu

Command Description
Add to... Run add_to command
Add to New File Run add_to_new_file command

Key Bindings

The following describe the default key bindings associated with AddToFile

Key Binding Command
f8 Run add_to command
ctrl+f8 (OSX cmd+f8) Run add_to_new_file command
shift+f8 Run smart_add_to command

Installation

AddToFile can be installed manually: 1. Download the .zip file or browse to the latest release 2. Unzip the .zip file 3. Rename to AddToFile 4. Move to the Packages directory which can be opened through Preferences --> Browse Packages...

Using package control: 1. Open Package Control 2. Type AddToFile