Of vim and other text editor hackery



  • I also resent the implication that I have a brain...


  • Banned

    @blakeyrat said:

    So backspace works on every keypress except the Tab key, where instead of Backspace you have to type "Shift-Tab". Which, BTW, has an utterly different meaning when a block of text is selected utterly unrelated to deleting a typoed Tab press.

    YOU HAVE CONVINCED ME.


    Yes, ignore the first sentence and make a snarky rebuttal to second sentence only. Keep in mind your shoulder alien's buttumption that I'm advocating for N++'s crappiness!



  • I wasn't talking about "N++" at all. I was just saying using spaces instead of tabs to do the thing tabs were specifically designed to do is fucking retarded as shit.


  • I survived the hour long Uno hand

    Pfft. Using tools that were designed for the job you're doing is SO last decade. If you can't do it in javascript using a text editor it's not worth doing at all!


  • BINNED

    @Yamikuronue said:

    If you can't do it in javascript using a text editor<textarea> control in a web-based editor it's not worth doing at all!

    FTFY



  • Now I have the strange compulsion to write a browser-based text editor using jQuery...



  • A sort-of jinx there...


  • I survived the hour long Uno hand

    You mean like http://ckeditor.com/ ?



  • Sweet! My afternoon just freed up!


  • ♿ (Parody)

    @Yamikuronue said:

    If you can't do it in javascript using a text editorwithout defining any named functions it's not worth doing at all!

    HPTFY



  • We should show this editor to the Discourse team... 🚎


  • ♿ (Parody)

    If only we could get an ancient version of TinyMCE...


    Filed Under: Fucking hell, why...etc, etc, etc


  • BINNED

    @tar said:

    We should show this editor to the Discourse team... 🚎

    Only if you add a function that every button on the toolbar has a 50% chance to fuck up your whole post on every click. Otherwise it won't be deemed worthy.


  • Discourse touched me in a no-no place

    @TwelveBaud said:

    FIND /N "something" some_stupid_non-ETW_trace.log | MORE /E /T4

    You should check out FINDSTR. Back when I was using Windows for serious, it was a sane replacement for grep (until I installed msys for a bunch of other tools).


  • Banned

    @blakeyrat said:

    I wasn't talking about "N++" at all. I was just saying using spaces instead of tabs to do the thing tabs were specifically designed to do is fucking retarded as shit.

    You weren't saying anything about tabs - you were saying that Backspaceing indents when using spaces is impossibru. Then you tried to disprove my point by saying that Shift+Tab is moronic idea (which it is, BTW) WHEN I MADE IT VERY, VERY CLEAR IT'S APPLICABLE ONLY IF YOUR TEXT EDITOR SUCKS BALLS. The only two logical explanations are that you were talking in context of N++, or that you don't read what you're quoting. Seems I gave you too much credit by assuming the former. I won't repeat the same mistake twice - so instead of going with the other logical explanation, I'm going to assume no logic at all in your posts.



  • Poop.


  • Banned

    2/10 needs more rant.



  • @tar said:

    Why would vim have some "magically transform arbitrary javascript" feature?

    Yet I was able to do it in sublime.

    @Onyx said:

    Hey, don't count me in the "vim brain trust". I just use the thing on remote servers when I CBA to mount the remote drive just to change a few config files. My vim knowledge is basic at best. And I don't care enough to learn more about it.

    Sry, hit in the crossfire :-)


  • Fake News

    @cartman82 said:

    What, really? The entire TDWTF vim brain trust can't come up with a way to do this basic thing?

    Where are all the vim champions who were urging me to drop my "bloated IDE-s" and invest two college degrees worth of time into chugging the vim cool-aid?

    Here I was merely correcting @Onyx about the fact that Vim has nothing like multiple cursors or other "live editing" for this particular use case and you want to turn it into a pissing contest.

    Still, trolling succeeded, here's one way to do it in plain Vim if you are on or before the a :

    /:<Enter>Dn.n._<Ctrl-V>$kkA",<Esc>gvI"<Esc>va{<Esc>r]`<r[va[JX

    EDIT: This does include replacing the braces with angle brackets near the end.

    For a shorter sollution, go post it on vimgolf.com and see how much people take up the challenge.

    Meanwhile I use Eclipse, Atom and Sublime (with and without their respective Vim modes), so maybe we should notificate @Captain for a more puritan view.


  • Discourse touched me in a no-no place

    @blakeyrat said:

    using spaces instead of tabs to do the thing tabs were specifically designed to do is fucking retarded as shit.

    QFT


  • Discourse touched me in a no-no place

    @Onyx said:

    a 50% chance to fuck up your whole post

    Doesn't Dischorse do that natively?


  • BINNED

    @loopback0 said:

    Doesn't Dischorse do that natively?

    That was the poi...



  • Oh I'm sure it can be done in Vim. That's the point.

    I was surprised that none of the people who declared themselves as any kind of vim user (casual or not) could come up with a way to do it. Considering it comes out perfectly naturally in the editors I use. And everybody is always suggesting vim as this great typing productivity boost.



  • I like Sublime, but haven't devoted much time to learning advanced features. I liked TextMate on OS X (sublime is pretty much a textmate clone). Sublime is different enough from both TextMate and Vim that I haven't felt the need to make the investment. I like that Sublime has a Vim mode -- but I'm not a hugely advanced Vim user and it's still missing keystrokes I like (I don't remember which -- I just remember getting mildly annoyed when a shortcut I type frequently didn't work). So the Vim mode is pretty basic. TextMate never had a Vim mode, but I think there was a plugin.


  • Discourse touched me in a no-no place

    Yes, but this way I got another dig at Dischorse in.

    And you should never pass up an opportunity to get a dig at Dischorse in.


  • Java Dev

    You could probably do it with the :map command. That allows binding a series of actions to one key (usually a function key). I don't tend to use it, because I tend not to write myself into these corners, and regex is more widely applicable. Usually . (to repeat the last command) does wonders.


  • Discourse touched me in a no-no place

    @loopback0 said:

    And you should never pass up an opportunity to get a dig at Dischorse in.

    But Dissedcaws isn't as bad as stabbing yourself in the eyes repeatedly with a hot poker, at least from a user perspective!



  • @cartman82 said:

    I was surprised that none of the people who declared themselves as any kind of vim user (casual or not) could come up with a way to do it. Considering it comes out perfectly naturally in the editors I use. And everybody is always suggesting vim as this great typing productivity boost.

    Your surprised that nobody's figured out how to do this one thing which nobody has ever wanted to do ever? That you already figured out to do in a different editor anyway? :wtf: Which we gave you a way to do which you discounted anyway? :wtf:


  • Discourse touched me in a no-no place

    @tar said:

    Your surprised that nobody's figured out how to do this one thing which nobody has ever wanted to do ever?

    IOW, @cartman82 is borrowing blakey's shoulder aliens. 😉



  • @tar said:

    Your surprised that nobody's figured out how to do this one thing which nobody has ever wanted to do ever? That you already figured out to do in a different editor anyway?

    WTF? I'm doing this all the time. If you're gonna use an advanced editor, this is like the ABC-s. Go to the sublime site, something like that is one of their animated examples.

    TRWTF is that you insist on using an advanced difficult to master editor like vim, and don't even know how to use it.

    @tar said:

    Which we gave you a way to do which you discounted anyway?

    I discounted the regex solution. You can use the fucking notepad if you're gonna write regex, that's not why you spend years mastering vim.



  • @cartman82 said:

    TRWTF is that you insist on using an advanced difficult to master editor like vim, and don't even know how to use it.

    I know how to do everything I need to do in Vim. If you don't want to use Vim because you don't understand it, that's perfectly fine, but this blatant concern trolling is not necessary.

    @cartman82 said:

    I discounted the regex solution. You can use the fucking notepad if you're gonna write regex, that's not why you spend years mastering vim.

    I use regexes all the freaking time. Or macros, whatever the right tool for the job is. You should probably stick to Sublime Text if that's what's working for you. I don't see anyone forcing Vim on you.



  • TIL vim advocates are indeed full of shit.

    Marking this thread for future reference if they try again shoving their cool aid down my throat.


  • Java Dev

    @tar said:

    I use regexes all the freaking time. Or macros, whatever the right tool for the job is. You should probably stick to Sublime Text if that's what's working for you. I don't see anyone forcing Vim on you.

    This. I don't need to remember stuff about editor macros because 9 times out of 10 the job can be done with grep, sed, awk, and friends, and my vim is running in a terminal anyway. Cases where you need to rewrite a structured static initializer like that are few and far between and don't warrant remembering editor tricks like that.

    The only trick along those lines I use with any frequency is having a (regex) search, then performing the same single editor operation (usually an insert or replace) at each location.



  • @cartman82 said:

    TIL vim advocates are indeed full of shit.

    Marking this thread for future reference if they try again shoving their cool aid down my throat.

    TIL that the only correct way to edit text files is to use Sublime Text. All other methods are Doing it Wrong™. Using regexes is Doing it Especially Wrong™.


  • ♿ (Parody)

    @cartman82 said:

    WTF? I'm doing this all the time.

    Holy shit. I can't recall ever wanting to do stuff like that. Probably because I haven't gotten the javascript worms yet.


  • Fake News

    Woah, and I thought this was going to end with a dud...

    @cartman82 said:

    WTF? I'm doing this all the time. If you're gonna use an advanced editor, this is like the ABC-s. Go to the sublime site, something like that is one of their animated examples.
    If we can move the goal posts to "common usage", I would actually put this in my configuration:

    vnoremap mA :s/\%V\(\w\+\):\s*\w\s*\([,}]\)/"\1"\2/g<Enter>
    

    Editing your example would then become va{ J gv mA and it should work without having to remember that regex.

    Of course, Sublime allows you to use Python, but then you're suddenly writing in a completely different language when the above is "just" Vim voodoo all the way down.
    There are many ways to skin a cat.



  • @JBert said:

    There are many ways to skin a cat.

    QFT. There are lots of different text editors, each with their own strengths and weaknesses. Let's have a fight about it.

    FWIW, I had a quick look at http://www.sublimetext.com/, and it looks reasonable. If I ever decided I want to pay money to use a text editor I might consider giving it a go.



  • @JBert said:

    ```
    vnoremap mA :s/%V(\w+):\s*\w\s*([,}])/"\1"\2/g<Enter>

    
    So I tested that and AFAICT it does exactly what was required. But here's the thing&mdash;can you make it so that it uses the same input as Sublime Text, and also make Vim behave exactly like Sublime Text and look exactly like Sublime text.
    
    I don't think that's possible! I reject this solution! It's worthless! :trollface:

  • Fake News

    There are no roads where you are trolling...

    So be careful, or I go on and show how you do the same for Sublime.



  • Guys. Mappings? Regexs?! I'm so dissapointed in the Vim brain trust today.

    Try starting at the { and do this:

    qqJa"Esce.ldeq2@qJ

    Which means:

    qq record
    J join lines
    a"Esc append quote
    e. another quote at the end
    l go right
    de delete to the end of the number
    q stop
    2@q replay twice
    J join lines

    I also didn't replace the {}. If you find yourself needing to do this a lot, I recommend the surround plugin. Then you can just do:

    cs{[ change surrounding { to [



  • That approach looks like it'll work as well, there's probably a couple others which are also viable. It's a testament to the power of the editor <x>:)

    Generally when trying to solve this kind of problem I usually go for a regex solution first, and try a macro if I'm out of luck with a regex. But you can get a surprising amount of leverage out of regexes if you're capturing groups. If I had to do a lot of fiddly formatting I'd probably try that with a macro first though...



  • Hey, you're free to use regexs if you like. I think Vim has the best regexs around -- mostly because I can't live without \zs.

    I'm just not so hot on everyone suggesting ugly regexs all the time. They just look like hell. Meanwhile all the main Vim commands like d to delete, e for end-of-word and . to repeat changes are simple. And usually they are all you need. And you can see if they're working as you go.

    Let's not forget, though, for the general version of this problem the real answer is to just have the computer do it for you. Type console.log(Object.keys(x)) at the end, select all the lines and type !nodejsEnter.

    I mean you're already on the computer, right?



  • @Gaska said:

    text editor ... starts up in less than second without SSD, has syntax highlighting and auto-indent, and I won't feel like an asshole for using it without paying?

    SciTE.



  • @Arantor said:

    it's 20-fucking-15 and we're still using FTP. To upload our software to our servers...

    What shit-grade server host do you use that doesn't allow ssh/scp?


  • Banned

    @flabdablet said:

    SciTE.

    I'm using SciTE sometimes on my Linux VM. It's awful in many ways:

    • text-only configuration
    • doesn't remember window size or position on exit
    • nothing prevents you from editing the same file in multiple instances
    • smart indentation sucks in it
    • no plugins
    • "find all" has been implemented the worst possible way
    • Spanish Inquisition

    But all that is understandable because it's NOT meant to be production-ready, but is just the Scintilla engine showcase.



  • @Gaska said:

    It's awful in many ways

    On the upside, it does meet all the criteria you originally listed.

    Filed under: be careful what you wish for, you might get it


  • Banned

    Except auto-indent. If some feature doesn't work well, then I don't count it. For example, Windows Vista/7 command prompt doesn't have tab-completion.



  • That's the sort of thing I'm imagining when I mention vim. None of that clunky regex shit.



  • @cartman82 said:

    None of that clunky regex shit.

    I'm still somewhat nonplussed by this attitude. Did a regular expression touch you when you were a child or something? What difference does it make whether you fix something using regexes or not?


  • Discourse touched me in a no-no place

    @flabdablet said:

    SciTE.

    Emacs. Come over to the dark side, (exclamation (have (we) 'cookies))


Log in to reply