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

Duplicate Lines

by wjthomas9 ALL

A modified version of the duplicate_line command for Sublime Text 2/3

Details

Installs

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

Readme

Source
raw.​githubusercontent.​com

Better Duplicate Lines command for Sublime Text

A modified version of the duplicate_line command for Sublime Text that allows you to duplicate multiple lines of text without worrying about the position of the cursor. If you use your keyboard to highlight the text you want to duplicate, this modified command is for you. (Although, I think it's better even if you use a mouse to select text too.)

I wasn't happy with the way the duplicate_line command was working in Sublime Text, so I made a modified version. This modified command will still duplicate a single line the same way. The behavior is slightly different, however, when duplicating multiple lines.

Rather than having to fully select the area to duplicate, you can now simply run your cursor selection over multiple lines, and this command will duplicate any lines that are even a part of the selection. So, if your cursor is in the middle of the line, it will still duplicate from the hard beginning of the first line in the selection to the end of the last line selected, and it will duplicate all of it directly below your selection. (The original command literally duplicates from wherever your cursor is positioned to where it ends, which created extra keystrokes for me.) This also means your selection no longer has to include empty space from the previous line to your selection in order to duplicate to a new line. It's a small difference, but if you prefer Eclipse-like behavior with this command, you'll like this.

Get it with the Sublime Text package manager

Note: If you've previously installed my command using the method above, it's a good idea to undo that before installing via package manager. (Remove the duplicate_lines.py file from the directory in the without package manager directions below, and remove the key command from your Key Bindings - User file.

  1. Launch Sublime Text Package manager
  2. Search for Duplicate Lines, and choose it to install it as a package.

Without Package Manager

  1. Download the repo
  2. In Sublime Text 2 or 3, go to Preferences -> Browse Packages
  3. Extract the contents to the folder
  4. Edit your Key Bindings - User file (and bind whatever command to it that you want)

{ "keys": ["super+shift+d"], "command": "duplicate_lines" }

{ "keys": ["super+shift+u"], "command": "duplicate_lines", "args": { "up": true } }

Enjoy.