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

Reform

by Suor ST2/ST3

A Sublime Text plugin to move through and reform things

Labels formatting

Details

  • 1.4.0
  • github.​com
  • github.​com
  • 10 months ago
  • 34 minutes ago
  • 4 years ago

Installs

  • Total 677
  • Win 242
  • OS X 300
  • Linux 135
Aug 17 Aug 16 Aug 15 Aug 14 Aug 13 Aug 12 Aug 11 Aug 10 Aug 9 Aug 8 Aug 7 Aug 6 Aug 5 Aug 4 Aug 3 Aug 2 Aug 1 Jul 31 Jul 30 Jul 29 Jul 28 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
Windows 0 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 1 0 0 0 0 0 0
OS X 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 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
Linux 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 2 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

Reform

Join the chat at https://gitter.im/Suor/sublime-reform

This thing enables you to move through and reform your code like magic. At least it aims to do it :)

Here is a list of supported commands:

Command Key* Description
find_word_up ctrl+up Jump to previous occurrence of a word at cursor
find_word_down ctrl+down Jump to next occurrence of a word at cursor
def_up alt+up Jump to previous function or class declaration
def_down alt+down Jump to next function or class declaration
smart_up alt+[ Jump to previous declaration or block2
smart_down alt+] Jump to next declaration or block2
move_word_right ctrl+alt+/ Swap word at cursor with a next one
move_word_left ctrl+alt+. Swap word at cursor with a previous one
move_block_up ctrl+alt+; Swap block with a previous one
move_block_down ctrl+alt+' Swap block with a next one
expand_next_word alt+d Expand selection to next word matching one at cursor1
select_scope_words alt+shift+d Select words in function scope matching word at cursor1,3
select_scope_up ctrl+shift+; Select block2/function/class at cursor, select enclosing one on next hit3
select_scope_down ctrl+shift+' Undo last select_scope_up
delete_block ctrl+alt+d Delete block at cursor with appropriate adjusting empty lines
extract_expr alt+enter Extract selected expression into an assignment4
inline_expr alt+= Inline variable defined on line at cursor

* Current key bindings are very experimental, especially on OS X.
1 Matches only whole words, case-sensitive, comments and strings are skipped.
2 Block is a adjacent commented lines or a blob of text surrounded with empty lines.
3 Works for python, js, plain text. Tries to work for other languages.
4 Works for python, js, ruby, php (and any languages with no keyword to define var).

Installation

  • Install Package Control.
  • Bring up the Command Palette with Ctrl+Shift+p (Cmd+Shift+p on OS X).
  • Select “Package Control: Install Package” (it'll take a few seconds).
  • Select or type in “Reform” when the list appears.

TODO

I have plans. Here is a list if you want to help and looking where to start:

  • Move functions up and down.
  • Better select words in scope: expand to next scope on subsequent hit, autodetect name scope.
  • Break long lines.
  • Break long strings, several variants including switching to multiline separators.
  • Reform dicts (object literals) from one-line to multi-line and back.
  • Same for calls, calls with keyword arguments, array literals.
  • Reform multiline list, set, dict comprehensions and generator expressions.
  • Align =, =>, :, \ and other punctuation
  • Switch brackets, parentheses, whatever.
  • Move blocks respecting functions.

Also, support for more programming languages for language-dependent commands will help.