Live data from Hacker News

Just Use Sublime Text

delvarworld.github.com

221–230 of 296 posts

Re: Just Use Sublime Text

#221
post #196
post #74

This seems overdone to me. Vim out of the box is a perfectly adequate text editor, and all you need to know to use it is /?xiap ESC 99dd :wq! and the arrow keys. With gq (formerly Q, RIP) you can then edit text. hlJG wbvn.fF;#% help too, especially for code, and c is nice, especially ci, which is a Vim innovation. ^F and ^B move around. Then, if you're programming, you probably want to build a tags file and use ^] an…

Vim out of the box is a perfectly adequate text editor, and all you need to know to use it is /?xiap ESC 99dd :wq! and the arrow keys. With gq (formerly Q, RIP) you can then edit text. hlJG wbvn.fF;#% help too, especially for code, and c is nice, especially ci, which is a Vim innovation. ^F and ^B move around. As somebody who never used Vim, I seriously can't tell if you are being sarcastic here.

I was being serious, but I appreciate that my brief precis above is impenetrable to someone who hasn't used some flavor of vi.

    / search forward regexp
    ? search backward regexp
    x delete character
    i insert before the cursor
    a insert after the cursor (useful at end of line)
    p paste ("put") the last thing you deleted
    ESC stop inserting (exit insert mode, return to command mode)
    99dd delete 99 lines
    :w RET save
    :q RET quit
    :w! RET save despite write-protection
    :q! RET quit discarding changes
    :wq save and, if successful, quit
    arrow keys move as usual.
That much gets you an editor better than Notepad (because of instant search, with bonus regexps; multiple line ending support; and large file support), if somewhat more confusing, which you can use via ssh, and which won't lose your unsaved work if your machine crashes or runs out of battery. (Although you have to learn the :recover command to recover that unsaved work.)

Occasionally you'll hit a wrong key and end up in some weird mode, which in Vim (unlike vi) displays at the bottom of the screen. Hit ESC to escape from the weird mode unless you feel like exploring it. If it split your screen and added another window (q: does this) then use :q to escape from it instead.

One more thing I forgot at first, which is kind of essential:

    u undo
    ^R (control-R) redo
For editing text, as opposed to code, you need to be able to refill (word-wrap) paragraphs so they aren't too ragged after you edit them. The command sequence {gq}, including the curly braces, will refill the paragraph your cursor is in.

That's 22 commands to memorize, which you can do in less than a day. That much already gives you an editor dramatically better than Notepad, and probably better than Pico or Nano, too. You can now move around very rapidly, insert and delete, cut and paste, save or discard changes, and refill paragraphs. Unix was written with editors less powerful than this.

For additional power, a second level of common commands, once you're comfortable with the 20 or so above:

    h move left (without having to take your hand off the home row)
    l move right
    G go to the end of the file
    1G go to line 1 (the beginning of the file)
    w move right by a word
    b move left by a word
    n repeat the previous / or ? search
    fe find the next "e" on the line
    Fe find the previous "e" on the line
    ; repeat the last f or F command
    % jump to the matching parenthesis, bracket, or brace
    # (or shift-click) search for the last occurrence of the word you're on
    ^F forward a page
    ^B back a page
Plus a few more editing commands:

    J join the next line onto this one
    > indent something (>> indent this line)
    
So that's another 25 or so commands, and now, after three days of vim, you can jump around in code like a madman (albeit in a single file); insert long method name identifiers with a few keystrokes; do interactive search and replace, using /, cw, n, and .; reindent blocks of code; and cut and paste in a more interactive way using v.

At this point you probably want to set a few options, which you can enter using : or put in your .vimrc without :.

    :set incsearch  makes / and ? search incrementally
    :set hlsearch  highlights search hits
    :syntax enable  enables syntax highlighting
    :set shiftwidth=4  makes  indent by four spaces
    :set autoindent  begins each new line with an indent
    :set expandtab  avoids putting TABs in the file (holywar)
    :set textwidth=72  auto-word-wrap at 72 columns
Except for the last one, you probably don't need to learn these; just leave them turned on all the time. They're mostly turned off by default for backward-compatibility.

There are some other commands I use on a regular basis (etyoIA*m',jkP|0^$^V^Z^GVC{}~:s) and others I use more rarely (Uq@, ZZ, :help, :set paste and :set nopaste, ^T and ^], ^W stuff, modelines, backreferences in regexp replacements) but I'm not confident that all of these are actually even valuable; I think knowing some of them just slows me down!

And of course there's lots more of vim I don't know at all (the jump list, quickfix, grep, spell-checking, cindent, cscope, abbreviations, editing files inside archives, the file explorer, folding, Arabic, Farsi, Hebrew, multiple buffers, key mapping beyond :map, and everything to do with plugins, to name a few areas).

Re: Just Use Sublime Text

#222
I disagree that you have "to read at least two books" about Vim to use it well. I learned it by co-workers, the web (pre-Google no less), and mostly through the Vim help itself.

Re: Just Use Sublime Text

#223
post #143

Almost anybody who associates great programming with things like super keyboarding skills and muscle memory is unfortunately degrading the status of programming to mere typing. What is it that is so distracting and pulling you out of your zen when you use a mouse? Seriously you type so fast and code at the speed of thought that a little glitch here is like making a mistake with a Formula 1 car in the Monaco Grand Pri…

Let me tell you how real work happens and how productive people work.

Thanks for condescending to all us unproductive children who obviously have never done any "real" work.

Guess what? That's called iterative design, and some very quality software is made the same way. It also has nothing whatsoever to do with arguing against using proper tools.

Here's a question: if your EE had to stop to deal with some clumsy tool (say, a soldering iron that was too big or had a badly designed handle), how badly would that impact his workflow? That's what people are talking about when they say that using the mouse when editing code (a purely textual medium, I might add) is a cache miss.

Re: Just Use Sublime Text

#224
I like Sublime Text, but I really can't use it for what I need a text editor for, which is Clojure. It is ridiculously bad at indenting/formatting Clojure and when I used it for any length of time I spent more time fixing the code it mutilated than I did actually working. I posted this bug report ages ago. If you're interested in doing Clojure in Sublime Text, upvote it! http://sublimetext.userecho.com/topic/98139-clojure-auto-ind...

Re: Just Use Sublime Text

#225
post #25

Am I the only person in the world who: a) Never thought vim was that hard to learn (and I first learned it when I was a teenager and nobody helped me. I switched when someone on a MUD made fun of me for using pico.) and b) Thinks vanilla vim works just fine. Seriously my vimrc is like 10 lines long and I don't even have it on every server I work on. I don't bother with any plugins. I don't need vim integrated with gi…

Am I the only person in the world who:

a) Never thought vim was that hard to learn (and I first learned it when I was a teenager and nobody helped me. I switched when someone on a MUD made fun of me for using pico.)

Yeah, I was rocking vi in high school, and I'm no genius, I had an ULTRIX vi reference card. The article's assertion that you have to read any books to use vim effectively is bullshit. As for the religion part, that usually comes in when someone tries to dictate what editor other people will use. I don't give a shit if someone on my project uses Eclipse or MSVS, just don't take my Emacs away.

Re: Just Use Sublime Text

#226
post #181

The area where sublime really wins for me is discoverability. Say I'm writing some markdown and I decide I want to preview it in the browser. A short key combo opens the command palette, I type install package, hit return, type markdown, see that there's a plugin called markdown preview, down arrow and return and it's installed in a couple of seconds. I open the command palette again, type markdown preview, hit retur…

With emacs, I type "M-x pai", which for me autocompletes to "package-install", and hit enter.

Then I type "mark", and from the completions see that there is a markdown mode I can install. Then I hit enter, and enjoy a new markdown mode!

I use emacs - I don't pretend it's the best thing ever. Vim does seem more conceptually pure, and Emacs is essentially an operating system.

But, goddamn, sometimes you just want to sand-blast that soup cracker. I learned Emacs and I have never had to learn anything else, because of the "M-x butterfly effect."

Re: Just Use Sublime Text

#227
post #182
post #117

Earlier quoted context omitted.

> what kind of medication the OP stopped taking The OP has a really "sane" take on things imho (yes, it's incredibly opinionated , but it's blog post featured on HN, not a SO question someone like you can close in minute :) - and I'm glad he bothered to write it, as I'd probably just send the link to it to any newbies asking me about "the magical vim" instead of bothering to tell them what I think) and he's right on…

What nonsense. It is absolutely incorrect that you have to 'keep Vim in your head just as much as the code that you're editing' unless you have not learned Vim at all. The reason you don't (constantly) have to think in ST or notepad++ is because you have already learned that editing paradigm. Although, that editing paradigm IS more obtrusive than vim's. It's abundantly clear that you do NOT understand vim's keybindin…

notepad++ is good enough for editing, not debugging, I didn't say that. I reject vim as a "general purpose programmer's text editor" and I reject recommending it to someone as such, but it's probably great for someone neck deep in nix sysadmining - actually that's what I use it for, on the server to quickly edit some configs, but on my laptop or desktop I just never touch it... and I also reject the vim way from a more "philosophical" pov: as an UI designer, I hate modal interfaces - if you have to think of or remember where you are, in order to know what you can do, or where to go in order do do some thing, then that UI needs a manual/guide, therefore it's broken by design (no, I never rtfm :) ).

Re: Just Use Sublime Text

#228
post #117
post #25

Am I the only person in the world who: a) Never thought vim was that hard to learn (and I first learned it when I was a teenager and nobody helped me. I switched when someone on a MUD made fun of me for using pico.) and b) Thinks vanilla vim works just fine. Seriously my vimrc is like 10 lines long and I don't even have it on every server I work on. I don't bother with any plugins. I don't need vim integrated with gi…

> what kind of medication the OP stopped taking The OP has a really "sane" take on things imho (yes, it's incredibly opinionated , but it's blog post featured on HN, not a SO question someone like you can close in minute :) - and I'm glad he bothered to write it, as I'd probably just send the link to it to any newbies asking me about "the magical vim" instead of bothering to tell them what I think) and he's right on…

eg. arbitrary multiple cursors (no other IDE or editor besides Notedpad++ has them yet, no matter how many users requested this for JetBrain IDEs for example)

Oh, you mean like this?

http://emacsrocks.com/e13.html

https://github.com/emacsmirror/multiple-cursors

Re: Just Use Sublime Text

#229

Earlier quoted context omitted.

> eg. arbitrary multiple cursors (no other IDE or editor besides Notedpad++ has them yet Emacs support for multiple cursors is also available: https://github.com/magnars/multiple-cursors.el

Visual Studio also has this with the MultiEditing plugin: http://visualstudiogallery.msdn.microsoft.com/2beb9705-b568-...

can it select, copy, paste and do zen-coding like expansions in multi-mode? if it can't do all of them or I can only use it to insert multiple cursors at search points (like the emacs multiple cursors plugin, sigh) I'll consider it useless for my workflow.

Re: Just Use Sublime Text

#230

Earlier quoted context omitted.

> reasonably productive after a few weeks Dear God. We're talking about a text editor.

Dear God, we're talking about what programmers spend the majority of their working hours using, for the foreseeable future. I suppose you never learn new programming languages, because god forbid, you're gonna be crippled for some time getting around new frameworks there and who really wants to make investments?

In all fairness, the argument being made is that learning vim is a waste of time for programmers on a deadline who don't already know it, or they wouldn't benefit from it. I have made the same argument about learning PHP, MATLAB and C# (while at the same time being eager to learn about just about any language new to me, eg, Go, Scala, Clojure, Haskell, etc).
Post reply on HN