Live data from Hacker News

Handy text manipulation tricks in Sublime Text 2

whiletruecode.com

61–70 of 99 posts

Re: Handy text manipulation tricks in Sublime Text 2

#61
post #52
post #46

Earlier quoted context omitted.

Have you actually tried Sublime? It has split windows. And you can extend is pretty easily using packages. I've read many posts of vi and Emacs hardcore users who actually liked Sublime.

Yes I have. My comment about split windows was about TextMate, which 4 years later still doesn't have them. (Coming in TextMate 2, which will be released sometime after Half Life 3.) Sublime has the eye candy, that I was talking about. It looks great. The 'birds eye' view is nice, but not particularly useful. There is nothing that it can do that it can do that Emacs/vim can't do or couldn't do with a few minutes of m…

I don't want to need a cheat sheet to use my text editor, I already need them for the programming language, the regexes, mathematical notation, etc. I don't want to spend a few minutes doing macros/scripting, I want to spend my minutes on the problem domain I'm actually working on. I don't like modes (see NO MODES in the Bret Victor talk), and I like positioning my cursor with a mouse.

I haven't paid for Sublime (yet), but I'm still much less annoyed by the occasional nag-boxes than by modes. I don't see a future in emacs/vim, but I am anxiously awaiting an intelligent editor such as LightTable.

Re: Handy text manipulation tricks in Sublime Text 2

#62
post #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.

[deleted]

Re: Handy text manipulation tricks in Sublime Text 2

#63
post #33

Earlier quoted context omitted.

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

This is all plain vim, so this'll work in MacVim, GVim and Janus (just MacVim and a bundle of plugins).

sorry i meant command / to toggle comments

Re: Handy text manipulation tricks in Sublime Text 2

#64
post #58

Earlier quoted context omitted.

This is the best explanation I've found so far: http://stackoverflow.com/a/1220118/3528

It was a very good read. But not what I was expecting. If vim is indeed speaking a language this is what I would expect a vim tutorial to have. 1. Basic commands. 2. Syntax to chain basic commands. 3. Ability to form other commands from basic commands. 4. Way to write macros. Instead most vim tutorials I have read present with a list of several commands to memorize and then a cheat sheet to navigate you through a jun…

Yup, you start with #1 there.

#2 doesn't really exist, so no need to learn it.

#3 is just using the commands in sequence. They aren't new commands.

#4 is advanced and I've never had a need for it yet.

Let's pick some apart:

ddp:

dd - delete line

p - paste line below

This swaps a line because when you delete a line, the line below it moves up and you end up on that line. When you paste an entire line, it pastes to the next line.

ddkP:

dd - delete line

k - move up 1 line

P - paste line above. (Shift usually means 'opposite direction', so it pastes above instead.)

I don't think of these as commands as such. I just think, I want to delete this line, and then I want to place it here. He's providing these as commands to show that Vim can handle the same features as Sublime Text, but he's doing it in a non-Vim way, as far as I'm concerned.

You don't memorize non-basic commands. You just use basic commands until you get what you need, and it happens that the advanced commands for most other editors can be done with just the basic commands of Vim.

Re: Handy text manipulation tricks in Sublime Text 2

#65
post #51
post #46

Earlier quoted context omitted.

Have you actually tried Sublime? It has split windows. And you can extend is pretty easily using packages. I've read many posts of vi and Emacs hardcore users who actually liked Sublime.

It's also closed source, meaning we can't fix something if we want to. We can't see what's going on back there. When it comes to a tool that I use every day with personal data, I really want it to be open source. My browser and my text editor definitely need to be open source. Additionally, Emacs is really amazing, and like many others, I've been building this init.el for years (in my case months), meaning Emacs and…

I actually did use the fact that MacVim is open source to fix a bug one day. Well, actually, someone else had already figured it out and provided a patch, but it wasn't in the main line yet and I really, really needed it that day. But I was already on the track to fixing it when I found someone else's patch.

Re: Handy text manipulation tricks in Sublime Text 2

#66
post #58

Earlier quoted context omitted.

It was a very good read. But not what I was expecting. If vim is indeed speaking a language this is what I would expect a vim tutorial to have. 1. Basic commands. 2. Syntax to chain basic commands. 3. Ability to form other commands from basic commands. 4. Way to write macros. Instead most vim tutorials I have read present with a list of several commands to memorize and then a cheat sheet to navigate you through a jun…

Based on this comment I think it's possible that vim isn't for you and you would probably be better suited to something like Sublime or TextMate.

Why would that be, vim seems to be difficult to use because a good manual that actually teaches how to use vim isn't available yet.

In fact it was surprising to me when I learned vim commands are actually a form of some terse language. Because I was only of an assumption that most vim commands are random string of characters you need to memorize. And when you memorize and practice enough you become productive.

I would be definitely well suited for vim, because I like terse language paradigms in unix like sed, awk, perl. I think if I had known about these aspects of vim a while back. I would have tried to write a few essays myself to understand using vim effectively.

I feel tempted to give vim a try now.

Re: Handy text manipulation tricks in Sublime Text 2

#67
post #58

Earlier quoted context omitted.

It was a very good read. But not what I was expecting. If vim is indeed speaking a language this is what I would expect a vim tutorial to have. 1. Basic commands. 2. Syntax to chain basic commands. 3. Ability to form other commands from basic commands. 4. Way to write macros. Instead most vim tutorials I have read present with a list of several commands to memorize and then a cheat sheet to navigate you through a jun…

Yup, you start with #1 there. #2 doesn't really exist, so no need to learn it. #3 is just using the commands in sequence. They aren't new commands. #4 is advanced and I've never had a need for it yet. Let's pick some apart: ddp: dd - delete line p - paste line below This swaps a line because when you delete a line, the line below it moves up and you end up on that line. When you paste an entire line, it pastes to the…

He's providing these as commands to show that Vim can handle the same features as Sublime Text, but he's doing it in a non-Vim way, as far as I'm concerned.

I'm all ears. What would be the Vim way?

Re: Handy text manipulation tricks in Sublime Text 2

#68
post #58

Earlier quoted context omitted.

This is the best explanation I've found so far: http://stackoverflow.com/a/1220118/3528

It was a very good read. But not what I was expecting. If vim is indeed speaking a language this is what I would expect a vim tutorial to have. 1. Basic commands. 2. Syntax to chain basic commands. 3. Ability to form other commands from basic commands. 4. Way to write macros. Instead most vim tutorials I have read present with a list of several commands to memorize and then a cheat sheet to navigate you through a jun…

1. "Basic commands" are what you know after 30 minutes of

    $ vimtutor
2. "Syntax to chain basic commands" is what you get when you think about what you are going to do. Like in any spoken or written language: "copy this line and paste duplicate it 10 times above" would be

    yy  copy this line
    10P paste above, 10 times
You have verbs (yank, paste, delete, join, move down…), direct objects (this word, this line, this html tag, this function, this paragraph…), indirect objects (up to this word, between line y and line x…) and, well… "counts" to do all that multiple times.

Vim's language is a lot more natural and intuitive and efficient than any variant of Cmd+Left - Shift+Ctrl+Right - Right - Cmd+c - Down - Cmd+v - Down - Cmd+v - Down - Cmd+v - Down - Cmd+v - Down - Cmd+v - Down - Cmd+v - Down - Cmd+v - Down - Cmd+v - Down - Cmd+v - Down - Cmd+v

Saying it's too arcane/complex/hard is just lying or being lazy.

3. "Ability to form other commands from basic commands" is achieved by writing small (or big) functions and bind them to your own commands.

4. "Way to write macros" is by not writing macros. You record a sequence of commands/keystrokes and run it later:

    qa   record a macro in register a
    yypj duplicate this line and move to the line below
    q    stop recording
    10@a apply the macro 10 times
No need for a cheat sheet if you are commited and don't rush it.

Re: Handy text manipulation tricks in Sublime Text 2

#69

Earlier quoted context omitted.

Yup, you start with #1 there. #2 doesn't really exist, so no need to learn it. #3 is just using the commands in sequence. They aren't new commands. #4 is advanced and I've never had a need for it yet. Let's pick some apart: ddp: dd - delete line p - paste line below This swaps a line because when you delete a line, the line below it moves up and you end up on that line. When you paste an entire line, it pastes to the…

He's providing these as commands to show that Vim can handle the same features as Sublime Text, but he's doing it in a non-Vim way, as far as I'm concerned. I'm all ears. What would be the Vim way?

As I said, learning the basic commands and using them. There's no need to remember a key combo for 'swap lines' because it's just 2 basic commands used in succession. I never even think of it as 'swap lines' because what I want to do is remove a line, then place it somewhere else. And that's what the commands are in Vim to make it happen.

Re: Handy text manipulation tricks in Sublime Text 2

#70
post #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…

jEdit has had this feature for a long time. It's one thing I miss, having moved to Vim.
Post reply on HN