Handy text manipulation tricks in Sublime Text 2
whiletruecode.com
Handy text manipulation tricks in Sublime Text 2
1–10 of 99 posts
Re: Handy text manipulation tricks in Sublime Text 2
#2Sublime Text 2 – Useful Shortcuts
Re: Handy text manipulation tricks in Sublime Text 2
#3For whatever it’s worth, all of these are copied directly from TextMate. :-)
Re: Handy text manipulation tricks in Sublime Text 2
#4My favourite feature is definently multiple cursors; Ctrl+D selects the next occurance of your highlighted word, Alt+F3 selects all occurances.
Re: Handy text manipulation tricks in Sublime Text 2
#5A few more handy ones:
Line Manipulation:
Select Line (press again to select subsequent lines): Command+L / Ctrl+L
Split multi-line selection into multiple selections, one per line:
Command+Shift+L / Ctrl+Shift+L
Delete to BOL: Command+Delete / Ctrl+Shift+Backspace
Delete to EOL: Control+K / Ctrl+K,Ctrl+K or Ctrl+Shift+Delete
Delete Line: Control+Shift+K / Ctrl+Shift+K
Insert Newline After: Command+Return / Ctrl+Enter
Insert Newline Before: Command+Shift+Return / Ctrl+Shift+Enter
Multiple Selections: Add next occurrence of current word to selection: Command+D / Ctrl+D
Select all occurrences of current word: Control+Command+G / Alt+F3
Undo through selection changes: Command+U / Ctrl+URe: Handy text manipulation tricks in Sublime Text 2
#6For whatever it’s worth, all of these are copied directly from TextMate. :-)
While I did try to be compatible with TextMate key bindings where possible, I believe only a handful of the key bindings mentioned in the article are actually common between the two.
Re: Handy text manipulation tricks in Sublime Text 2
#7I've changed some key bindings to suit my taste, like:
Cmd-D: Duplicate line
Cmd-L: Delete line
Cmd-T: Insert HTML tag
Cmd-B: Open in browser
Ctrl+Up/Dn: Toggle lines
Ctrl+a/e/i/o/u: Accented á é í ó ú
Sublime Text 2 has become my favorite editor, fully customizable and plenty of plugins available.Re: Handy text manipulation tricks in Sublime Text 2
#8Sublime Text makes me feel silly for loving a text editor so much. Now if only it would do text completion across multiple files...
Re: Handy text manipulation tricks in Sublime Text 2
#9My favorite: in HTML editing mode you can press Ctrl-Shift-A to select enclosing tag and modify both open and close tag at the same time. Very handy when editing HTML files (although I'm not sure if this is Sublime's built-in or from any third party package I installed.)
Re: Handy text manipulation tricks in Sublime Text 2
#10Vim equivalents if you're feeling jealous (matching the order in the article):
J Join line.
ddp Swap line with the one below.
ddkP Swap line with the one above.
dd Delete current line
yyp Duplicate line
gq} Rewrap a paragraph.
Vu Lowercase a line
VU Uppercase a line
Sort the selection by the Unix `sort` command (eg. sort -rn for reverse numeric order): V
:!sort
It goes a bit pear-shaped for these ones, though: Title-Case:
:s/\/\u\1\L\2/g
Twiddle/Flip Case:
function! TwiddleCase(str)
if a:str ==# toupper(a:str)
let result = tolower(a:str)
elseif a:str ==# tolower(a:str)
let result = substitute(a:str,'\(\\)', '\u\1', 'g')
else
let result = toupper(a:str)
endif
return result
endfunction
vnoremap ~ ygv"=TwiddleCase(@")Pgv
I'm a bit stumped on toggling comments, though. Any ideas?