Live data from Hacker News

Vim Creep

rudism.com

221–230 of 237 posts

Re: Vim Creep

#221
post #218

Earlier quoted context omitted.

Yes, the minimap is what you guessed it was. Other ST features that Vim/Emacs don’t have (by default, at least): • You can use proportional fonts (I use Verdana) • The interface chrome is graphical, not text in a grid. This allows nice details such as a drop-shadow from the minimap when it covers the text and proportional fonts in the file tree’s filenames. • On a Mac with smooth scrolling, you can scroll smoothly pi…

"It’s too bad Sublime Text isn’t open source." Bad bad bad, if you are investing time in mastering a tool which could disappear tomorrow, or take a direction you don't like. This is one of the strongest reasons I chose GNU Emacs as my editor. I remember how burned I was when Visual Studio moved from VBScript to .NET as its macro language. All the time I had invested in learning its macro system and in writing macros…

To be completely fair, it's not like they are going to remotely delete it or anything, the current version which I like functions, and has no glaring bugs, and will continue to function.

And if I did use emacs, and somehow it changed in a way that I hated, I really doubt I'd have the time to fix it. Work isn't going to pay me to sit around and write my own text editor.

Re: Vim Creep

#222
post #187

"Knife skills" don't make you a good developer. Cook a great steak and worry less about cutting it. Tools are boring. People are far more important. A post like this is akin to "I LOVE BRITNEY SPEARS." Please God, make the programmer pop culture stop.

Coincidentally, I've been working on my knife skills lately. In the past, I often served dinner late because I took so long to chop the vegetables. (I'm vegetarian.) Now that I'm focusing on proper knife technique to chop quickly, I find that I can get dinner served faster — but also I have more flexibility to respond and experiment in the kitchen, because I can, for example, put the skillet on the stove before I start chopping the onion I'm going to sauté. And I'm less likely to burn things, because chopping takes less of my time and attention.

Of course, knowing how to cut isn't the same as knowing how to cook. Vegetables chopped slowly taste the same as vegetables chopped fast. But if you already know a thing or two about food, you can cook a little bit better if your cutting technique is better.

Re: Vim Creep

#223
post #182
post #96

Earlier quoted context omitted.

I recently discovered a way to learn Vim without fear: learn undo ('u') first! If you know that, you can just mess around with Vim commands until you inevitably screw something up, undo the changes, relax, take a deep breath, and Google whatever you're trying to do.

If you are familiar with vim, install gundo.vim and enjoy traversing your undo tree.

Awesome.

Re: Vim Creep

#224
post #219
post #203

Earlier quoted context omitted.

> You've quite obviously never tried to code anything in vimscript, have an axe to grind with Python, or are Tim Pope All your claims are preposterous. I have coded in Vimscript, I use Python and have no axe to grind; and I am not Tim Pope(duh). > Vimscript is a horrible abomination that's painful to do just about anything in. Python is far, far superior. I don't remember claiming Python is inferior to vimscript. Hav…

> Vimscript is not a general purpose programming language, but does the job of extending vim fine. If you have the chance to choose to invest time in learning either a language to extend your editor or a general purpose language which you can use to extend your editor, which would be your best bet?

> If you have the chance to choose to invest time in learning either a language to extend your editor or a general purpose language which you can use to extend your editor, which would be your best bet?

It's not as uni-dimensional. Sure if I don't know either of Vimscript or Python, I will see learning Python as more beneficial. But the main reason vim chose vimscript(or emacs chose elisp) is you have a interpreter built in the editor itself. If all your extensions are vimscript, all you need to configure vim on a new box is to copy your .vimrc and .vim folder and everything will work - no package installation, no external dependencies.

If you already know vim and some programming, you can start writing basic vimscript in an hour or two. The more complicated ones(the ones Time Pope writes) are going to take a lot of time, irrespective of your language choice.

Also, vim extensions can be written in Python as well, but it requires that your vim has python support. How does ST does it? Does it bundle python?

Re: Vim Creep

#225

Earlier quoted context omitted.

It's all about building up a maximally powerful keyboard text editor from potent primitives. When it comes to out-of-the-box editors, nothing gives more bang for the buck on arbitrary text files than vim. That's not to say it's the best overall. If you like to customize your environment, emacs is better. If you like tight OS integration and advanced GUI features, many editors are better. If you want the most producti…

Thanks, I really appreciate how you broke it down. One thing that I was wondering about that you don't address directly is: how do you compile/execute your code? Do you have to exit vim every time, run your compile/execute command, then relaunch vim? Sorry if this is really specific.

In vim, you can execute shell commands straight from the main command mode (the default mode starts in). For a C project, compiling might be as simple as typing:

:!make

Then run with:

:!./myprog

In both cases, the output will be viewable in a temporary window. You can also pipe the output of a shell command into a vim buffer (aka file) by prefixing you command with "r":

:r !./myprog

This takes all the output from ./myprog and lets you view/edit it in vim.

If your language has a more involved build process, chances are someone has written a plugin to help you and posted it on the vim scripts page: http://www.vim.org/scripts/script_search_results.php.

Enjoy :)

Re: Vim Creep

#226

Earlier quoted context omitted.

Thanks, I really appreciate how you broke it down. One thing that I was wondering about that you don't address directly is: how do you compile/execute your code? Do you have to exit vim every time, run your compile/execute command, then relaunch vim? Sorry if this is really specific.

In vim, you can execute shell commands straight from the main command mode (the default mode starts in). For a C project, compiling might be as simple as typing: :!make Then run with: :!./myprog In both cases, the output will be viewable in a temporary window. You can also pipe the output of a shell command into a vim buffer (aka file) by prefixing you command with "r": :r !./myprog This takes all the output from ./m…

For longer and more interactive shell interactions you can use job control, if your shell supports job control (bash, zsh and pretty much every reasonable user shell in existence). Ctrl-Z will suspend vim and drop you back into your shell, you can then unsuspend vim by running "fg" (at least in bash).

Alternatively, my own work flow consists of using tmux to have a split screen terminal, Vim left, REPL right.

Re: Vim Creep

#227
post #224
post #219

Earlier quoted context omitted.

> Vimscript is not a general purpose programming language, but does the job of extending vim fine. If you have the chance to choose to invest time in learning either a language to extend your editor or a general purpose language which you can use to extend your editor, which would be your best bet?

> If you have the chance to choose to invest time in learning either a language to extend your editor or a general purpose language which you can use to extend your editor, which would be your best bet? It's not as uni-dimensional. Sure if I don't know either of Vimscript or Python, I will see learning Python as more beneficial. But the main reason vim chose vimscript(or emacs chose elisp) is you have a interpreter b…

The problem with application-specific extension languages is that they may start underpowered and ad-hoc, whilst general purpose languages have already proved their worth and done so in several domains.

Vim designers tried to reinvent the wheel and failed to implement a decent extension language from the beginning, whilst GNU Emacs designers didn't reinvent the wheel and adapted a mainstream general purpose language to their needs. So, while Vim users were busy wrestling with the limitations of their extension language and coping by adding ad-hoc extensions here and there, Emacs users were busy churning out macros and packages for their editor.

The main reason I have chosen Emacs as my editor is that I get more bang for the buck. Emacs can emulate Vim, whilst the opposite is not true, as the folks who tried to port SLIME (a powerful package to code in Common Lisp) realized.

We agree that an embedded extension language is the way to go. And whatever mainstream language you might choose, it could go out of fashion after a while anyway.

Re: Vim Creep

#228
post #227
post #224

Earlier quoted context omitted.

> If you have the chance to choose to invest time in learning either a language to extend your editor or a general purpose language which you can use to extend your editor, which would be your best bet? It's not as uni-dimensional. Sure if I don't know either of Vimscript or Python, I will see learning Python as more beneficial. But the main reason vim chose vimscript(or emacs chose elisp) is you have a interpreter b…

The problem with application-specific extension languages is that they may start underpowered and ad-hoc, whilst general purpose languages have already proved their worth and done so in several domains. Vim designers tried to reinvent the wheel and failed to implement a decent extension language from the beginning, whilst GNU Emacs designers didn't reinvent the wheel and adapted a mainstream general purpose language…

> The problem with application-specific extension languages is that they may start underpowered and ad-hoc, whilst general purpose languages have already proved their worth and done so in several domains.

The embedded language has to be small, easy to learn, and most importantly, it should serve the purpose of extension. If it can serve other domains as well, that isn't really relevant as far as the editor is the concerned. Now vimscript doesn't do threading or evented io or thousands of other things - it isn't meant to do any of those.

> whilst GNU Emacs designers didn't reinvent the wheel and adapted a mainstream general purpose language to their needs.

Lisp can hardly be considered a mainstream, general purpose language(may be it was at the time they were adding it to emacs).

The point of vimscript wasn't to win any language design awards, but to have a langauge with a very small core which can be used for configuration and extension. As far as quirks go, all languages have quirks. PHP and JS probably have more quirks than Vimscript. Since you are so critical of Vimscript, care to cite me the pain-points which stop you from writing decent extensions in vimscript? There are a variety of scenarios in which vimscript implementation is much more simpler to an elisp implementation.

Consider this sample grap extension take from Steve Losh's http://learnvimscriptthehardway.stevelosh.com/chapters/34.ht...

    nnoremap g :set operatorfunc=GrepOperatorg@
    vnoremap g :call GrepOperator(visualmode())

    function! s:GrepOperator(type)
        let saved_unnamed_register = @@

        if a:type ==# 'v'
            normal! `y
        elseif a:type ==# 'char'
            normal! `[v`]y
        else
            return
        endif

        silent execute "grep! -R " . shellescape(@@) . " ."
        copen

        let @@ = saved_unnamed_register
    endfunction
And usage:

    viwg: Visually select a word, then grep for it.
    g4w: Grep for the next four words.
    gt;: Grep until semicolon.
    gi[: Grep inside square brackets.
Are you saying elisp implementation of the same concept(provide me a way to grep for arbitrary grep for words, and no, spawning a shell isn't the same thing) is going to be shorter or simpler?

> While Vim users were busy wrestling with the limitations of their extension language

I would really like examples where the limitation of vimscript is outshined by elsip. Check my snippet above - vimscript is written specifically for extending vim, and it does a good job.

> Emacs users were busy churning out macros and packages for their editor.

I find recording macros in vim simpler than emacs. By default. Vim doesn't have a save macro functionality, but either you use an extension to do that, or manually save the macro.

> The main reason I have chosen Emacs as my editor is that I get more bang for the buck.

It mostly boils down to this "I get more bang for the buck". There is not much objectiveness when it comes to vim and emacs. You enjoy emacs, I enjoy vim.

> Emacs can emulate Vim,

A very limited form of vim navigation.

> whilst the opposite is not true, as the folks who tried to port SLIME (a powerful package to code in Common Lisp) realized.

I didn't know about an attempt to port slime to vim, because you will have to fight vim for it, and vim won't yield. Vim doesn't do async processes and per the developers, it's not going to, period. So, no shells in the vim(you can folk a shell but then the editor goes away and when you exit the shell, you are back in the editor), no debugger, no slime...It's a conscious design decision. If you don't like it, use something else.

Re: Vim Creep

#229
post #121

Earlier quoted context omitted.

For rhetorical effect, `:wq` is right. But in the real world, `:x` is the better choice.

I still use `:wq` once every blue moon. Only out of habit though.

Same here ... I'd ask people why you wanna do two keystrokes when you understand when to :x. Creatures of habit. One thing I dislike though is accidentally having my shift key pressed which converts the :x to :X and Vim thinks I want to encrypt the file.

Re: Vim Creep

#230
post #228
post #227

Earlier quoted context omitted.

The problem with application-specific extension languages is that they may start underpowered and ad-hoc, whilst general purpose languages have already proved their worth and done so in several domains. Vim designers tried to reinvent the wheel and failed to implement a decent extension language from the beginning, whilst GNU Emacs designers didn't reinvent the wheel and adapted a mainstream general purpose language…

> The problem with application-specific extension languages is that they may start underpowered and ad-hoc, whilst general purpose languages have already proved their worth and done so in several domains. The embedded language has to be small, easy to learn, and most importantly, it should serve the purpose of extension. If it can serve other domains as well, that isn't really relevant as far as the editor is the con…

> Now vimscript doesn't do threading or evented io or thousands of other things - it isn't meant to do any of those.

Neither does Emacs Lisp. But whilst Emacs Lisp started as a simplification of a battle-tested general-purpose language, Vim Script started as a hack and continued that way, with further functions being added on a "as-needed" basis.

> As far as quirks go, all languages have quirks. PHP and JS probably have more quirks than Vimscript.

Effective analogy. PHP and Javascript started as hacks as well, they weren't meant to do much at first, and shared the same fate of Vim Script. The reason people put up with PHP and Javascript is that they had or have no alternative. And if there were no modal editor other than Vim, I myself would put up with Vim Script as well.

> Since you are so critical of Vimscript, care to cite me the pain-points which stop you from writing decent extensions in vimscript? There are a variety of scenarios in which vimscript implementation is much more simpler to an elisp implementation.

This is what we could name a "Perl fallacy": Perl scripts can be much shorter than scripts in other languages, but the former are more of a PITA to write.

However, I can cite a pain point: I can't write stand-alone applications with Vim Script. You may say this does not matter, because we are talking about extension languages here, but my view is different (and this was one of the original objections of mine). Why learn shell scripting (or something similar), different command-line text processing tools with their quirks when you can learn one framework well and use it for everything?

Evidence shows that Emacs' packages can go beyond Vim's, even when we factor out the kitchen-sink approach of Emacs. For instance, whilst Emacs programming packages parse - thus understand - code while perform syntax-highlighting, Vim's packages rely on regexps, thus messing syntax-highlighting when the syntax of a language is not quirky.

I don't understand your grep example, but providing an Emacs Lisp implementation would be pointless anyway. Languages are not to be judged so much by the terseness of their programs in specific cases as by their consistency and easiness of reading in general cases. Vim Script code is difficult to read because uses keyboard macros heavily, and suffers from accumulated cruft, where equivalent Emacs code would use named procedures with meaningful and consisten names.

> I find recording macros in vim simpler than emacs.

By "macro" I meant procedures, not keyboard macros.

> It mostly boils down to this "I get more bang for the buck". There is not much objectiveness when it comes to vim and emacs. You enjoy emacs, I enjoy vim.

I wish this were the case, but it is not. There is objectiveness. By learning Emacs, you are learning how to use a tool which is much more consistent and flexible. Since the learning effort is comparable, why would you choose otherwise? Concentrated effort on worthwhile tasks leads to higher returns.

>> Emacs can emulate Vim, > A very limited form of vim navigation.

Current Emacs packages emulate Vim as far as it is useful. Cloning Vim wouldn't make sense as there are equivalent Emacs facilities.

> I didn't know about an attempt to port slime to vim, because you will have to fight vim for it, and vim won't yield. Vim doesn't do async processes and per the developers, it's not going to, period. So, no shells in the vim(you can folk a shell but then the editor goes away and when you exit the shell, you are back in the editor), no debugger, no slime...It's a conscious design decision. If you don't like it, use something else.

I acknowledge that the kitchen-sink approach of Emacs has lead to aberrations (like Gnus), at which Vim users laugh, but the superiority of Emacs would persist even if you stripped out facilities that Vim doesn't offer by design choice.

You know what, Irahul? I like Vim. Really. I have studied many Vim books and lurked on Vim Wiki and Vim enthusiast's blogs. I have never learned how to use Emacs' default editor properly, as I switched to a Vim emulator early. Emacs has an effective editor implementation, Vim has an effective editing model. That's what is objective. Thankfully, we don't have to choose anymore.

Back to work ;-)

Post reply on HN