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 330
  • Win 272
  • OS X 33
  • Linux 25
Dec 10 Dec 9 Dec 8 Dec 7 Dec 6 Dec 5 Dec 4 Dec 3 Dec 2 Dec 1 Nov 30 Nov 29 Nov 28 Nov 27 Nov 26 Nov 25 Nov 24 Nov 23 Nov 22 Nov 21 Nov 20 Nov 19 Nov 18 Nov 17 Nov 16 Nov 15 Nov 14 Nov 13 Nov 12 Nov 11 Nov 10 Nov 9 Nov 8 Nov 7 Nov 6 Nov 5 Nov 4 Nov 3 Nov 2 Nov 1 Oct 31 Oct 30 Oct 29 Oct 28 Oct 27 Oct 26
Windows 1 2 1 0 1 3 1 1 0 0 2 4 2 3 2 2 1 1 2 5 1 2 2 4 2 2 2 2 4 2 1 1 3 1 6 0 1 0 1 3 3 3 0 2 1 1
OS X 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 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 1 0 0 0 0 0
Linux 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 0 1 0 0 0 0 0 0 1 0 0 0 1 0 1 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