Live data from Hacker News

Handy text manipulation tricks in Sublime Text 2

whiletruecode.com

31–40 of 99 posts

Re: Handy text manipulation tricks in Sublime Text 2

#31

Sublime Text makes me feel silly for loving a text editor so much. Now if only it would do text completion across multiple files...

Is there a CTags plugin you can use?

Yup, this - https://github.com/SublimeText/CTags Install from package control.

Re: Handy text manipulation tricks in Sublime Text 2

#32
I'm doing Google App Engine Python stuff with Sublime Text 2.

Is there any way to get it to somehow guess at function signatures? So if I start writing do_something(... I could see the args that do_something() expects. Assuming it's just a function that is plainly defined somewhere in my project folder would be enough for me.

Another thing is when I am testing the app in localhost and it spits out error messages indicating the line number(s) where I sinned, it would be nice to somehow be able to jump to them.

Re: Handy text manipulation tricks in Sublime Text 2

#33

Vim 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-…

I think macvim has this because I've been doing it for as long as i remember, or maybe it's in Janus though.

Re: Handy text manipulation tricks in Sublime Text 2

#35
Any article that talks about tricks in Sublime Text 2 without mentioning Multiple Cursors is... lacking (no offense to the OP).

For anyone that doesn't know it, Multiple Cursors is the ONE BRILLIANT FEATURE that Sublime Text has. Don't get me wrong, tt's great in many other ways too, but Multiple Cursors is, IMO, a feature that should become part of every friggin' text editor in existence, it's that important. And it only exists in Sublime Text.

It gives you multiple cursors at seperate places in your document. Each one acts completely independently, moving around with your commands. Everything works as expected, including copy-pasting (it will match the copy-pastes up to your cursors).

Most text editors have a column-select mode, except that Multiple Cursors are the same thing on steroids:

1. The selections don't have to be contiguous. So if you have a bunch of:

  

Text And more Text

Something

You can put the cursor only on the

s.

2. Since each cursor acts independently, you can do operations that you simply can't do in column mode. For example, place the cursor on each

, select to the end of that

, and delete the text. This is even if the contents of the

are completely different.

3. Multi Cursor gives the same power as macros, but: They're visual! You see all the changes you're making in realtime. Any long-time vim user has probably recorded a macro, tried playing it back, and discovered that it didn't work. Well, with Multi Cursors, you see the cursor and changes in real-time. Make a wrong command? Undo it instantly.

Want an example of another actual use case? I used to have a plugin for Sublime Text that let me split a selection into multiple selections, based on a character. So, let's say I had this code:

foo(int a, char b, char c)

I could select the paramater list, run my shortcut to split by ",", then I'd get a different selection on each paramater. Then, I could simply multi-select three lines below it inside the actual function, paste, and I've got this code:

foo(int a, char b, char c)

  int a

  char b

  char c
A dead-simple editing task I do 300 times a day.

Another example? Let's say I have two "if" blocks in the top of a function:

if (somecondition):

  return
if (anothercondition):

  return
Now, let's say for a second that I just realized I don't want to return, I want to do some processing, then return. This happens a few times a day for me. I just multi-select both "if"s, hit enter, and add the code. If it's two functions and I need to use the function names, I can even go back, copy the function name, and paste it as part of the processing!!

Phew. If it seems I'm a fanboy for Multiple Cursors, I totally am. It's a brilliant tool that only exists in Sublime Text. I've unfortunately gone back to Vim, and am too far in Vim's world to manage working in Sublime Text, which is why I miss multiple cursors so much!

But I AM working on a Vim plugin that gives Vim Multiple-Cursors. Been working on it for a while, but I think I'm getting near a more-or-less stable version. Hopefully, it will be released soon.

Re: Handy text manipulation tricks in Sublime Text 2

#38
post #32

I'm doing Google App Engine Python stuff with Sublime Text 2. Is there any way to get it to somehow guess at function signatures? So if I start writing do_something(... I could see the args that do_something() expects. Assuming it's just a function that is plainly defined somewhere in my project folder would be enough for me. Another thing is when I am testing the app in localhost and it spits out error messages indi…

Have you seen CodeIntel? https://github.com/Kronuz/SublimeCodeIntel

Re: Handy text manipulation tricks in Sublime Text 2

#39
post #30

Earlier quoted context omitted.

That's interesting. Can you edit all selected occurrences at once? I don't think there's an immediate analogue in Vim.

There is no analogue in Vim. It's the one thing I hate about vim.

:%s/original/new/g

Re: Handy text manipulation tricks in Sublime Text 2

#40

Now that I've gotten used to first class refactoring support in the Jetbrains products any other editor just seems archaic. IntelliJ has all the features mentioned in this article and intelligent code restructuring.

Does it allow you to have multiple projects open at the same time yet? That was what prevented me from using it earlier.

Yes:

http://www.jetbrains.com/idea/webhelp/opening-multiple-proje...

Post reply on HN