Of vim and other text editor hackery



  • @superjer said:

    Looks like Audacity uses GTK.

    IIRC, they use wxWidgets, which uses GTK on Linux and (mostly) native Windows stuff on Windows.


  • Fake News

    @Arantor said:

    None of the plugins have ever seemed especially useful.

    I love the "XML tools" plugin because it allows to work with nested XML comments:

    [code]
    <!--<colors background_text_opacity="255"> <color id="0" r="0" g="0" b="0"/> <color id="1" r="0" g="0" b="128"/> <color id="2" r="0" g="150" b="0"/> <color id="3" r="0" g="150" b="150"/> <!{1}**<color id="4" r="170" g="25" b="25"/>**{1}> <color id="5" r="128" g="0" b="128"/> <color id="6" r="128" g="128" b="0"/> <color id="7" r="192" g="192" b="192"/> <color id="8" r="128" g="128" b="128"/> <!{1}**<color id="9" r="0" g="100" b="255"/>**{1}> <color id="10" r="0" g="255" b="0"/> <color id="11" r="0" g="255" b="255"/> <color id="12" r="255" g="50" b="50"/> <color id="13" r="255" g="0" b="255"/> <color id="14" r="255" g="255" b="0"/> <color id="15" r="255" g="255" b="255"/> </colors>-->
    [/code]
    Granted, the real WTF is XML / HTML but at least this makes it slightly more bearable.



  • @Onyx said:

    FUCK THAT SHIT! Fucking spaces bullshit, it's just a PITA all around, I still haven't seen a single valid reason to do that.

    Chill out. Both spaces and tabs are fine - as long as they're not mixed together. Because of that last bit, I'm spaces supporter - because if your line exceeds length limit, space-aligning looks nicer than double-indent or whatever you do with tabs.



  • @Arantor said:

    Plugin != built-in

    If the plugin can be installed from within the application itself, it's hardly any different than a built-in feature that's disabled by default.



  • @Gaska said:

    Both spaces and tabs are fine - as long as they're not mixed together.

    Heretic! The only correct indenting is such that every 8 spaces get replaced by a tab </ :trollface: >

    (Yes, that's default in both ViM and Emacs, why do you ask?)



  • If the editor is set to spaces, you typo one character (tab), then you have to hit backspace 4 times to delete it.

    You end up with this magical fairyland key that behaves differently from every other key on the keyboard.

    Spaces are fucking stupid for that reason alone.


  • SockDev

    And that's why I like editors that can auto-layout my code blocks :smile:


  • BINNED

    @blakeyrat said:

    Spaces are fucking stupid for that reason alone.

    Addendum: if someone decides to format a file using 2 spaces for indentation (which I think is not enough), or 8 spaces (which I think is too much) the only way for me to use my preferred indentation (4 spaces) I have to re-format the whole file. And then, when I return the changed file back it's not to that person's liking, and it's the same shit all over again.

    With tabs, I just set tab width in my editor and I'm done.



  • @blakeyrat said:

    If the editor is set to spaces, you typo one character (tab), then you have to hit backspace 4 times to delete it.

    Only if you're using a shitty text editor. But even those support Shift+Tab.

    @blakeyrat said:

    You end up with this magical fairyland key that behaves differently from every other key on the keyboard.

    How so? All that this key does is send WM_KEYDOWN message with its scancode, just like every other key. Oh, you mean that this one application is smart enough to react to this key being hit exactly the way I want? Why, that's wonderful!

    The tab character, on the other way, changes the perceived content of text file depending on which of the three standard conventions the tool used to open it follows. Do you remember, back in the days of IE6 and FF2, there were those websites that looked slightly off on one or the other, and it pissed people off to no extent because suddenly the buttons were all in the wrong places? I have this same feeling whenever I open a document in something that doesn't use 4-space tabs. Not to mention it's often impossible to use it for aligning stuff horizontally - something that's very important when working in languages where an expression often exceeds 300 characters in width so you need to break it down in multiple lines.

    @Onyx said:

    With tabs, I just set tab width in my editor and I'm done.

    How do you deal with stuff like this:

    message_handler.register_executor(std::make_shared<RequestBoardData>(board.get_name(), std::bind(&module_configurator::process_board_data, this, _1)));
    

    Or anything else that should go into a single line but is too long?



  • @Gaska said:

    Oh, you mean that this one application is smart enough to react to this key being hit exactly the way I want?

    Like this one that opens a context menu. Then there's stuff that doesn't seem to do anything at all. Clear. I still have no idea what that (where NumLock would normally be) is supposed to do.



  • My trace logs can go into the gigabytes. Though vim dislikes them if they get over 1-2 gigs, and I switch to less instead.

    Naturally, I can par them down with grep first if needed. But windows users don't have that option now do they?



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

    /N and /T4 are my personal preferences, YMMV.


  • Fake News

    Or just use grep and less for Windows.

    Though I must admit your solution has the "out of the box" advantage...



  • My problems with notepad++ are mostly that it keeps annoying me with updates and doesn't have an easy way to say "always use syntax highlighting X when opening file mask Y" (I know there's a way, but no easy way).

    Also, some of the features of sublime are so great, they are basically "killer" at this point. Namely, global search of all options (Ctrl + Shift + P) and vertical cursor fuckery. Not to mention it works everywhere, unlike nodepad++ which is Windows only.

    I still have npp as default in some apps, but unless something changes, I see sublime slowly pushing it out over time.


  • BINNED

    @cartman82 said:

    vertical cursor fuckery

    I found several applications where CtrlAltLeft_Mouse does the block select thing. Namely, I know it works in Qt Creator and Gnome Terminal, can't remember if there were more right now. I'm starting to wonder if it's some kind of unwritten "standard" at this point.



  • In Visual Studio, SQL Server Management Studio, and WebMatrix, AltLeft_Mouse does that.

    In the Command Prompt, Left_Mouse does that. :stuck_out_tongue_winking_eye:


  • Fake News

    @cartman82 said:

    My problems with notepad++ are mostly that it keeps annoying me with updates and doesn't have an easy way to say "always use syntax highlighting X when opening file mask Y" (I know there's a way, but no easy way).
    Do you want to match the complete filename or just the extension? The latter is do-able.

    @cartman82 said:

    vertical cursor fuckery

    Do you mean block select? If you ever happen to be stuck in Notepad++, try Alt + Mouse drag.


  • BINNED

    @TwelveBaud said:

    In the Command Prompt, Left_Mouse does that.

    My favouritest feature in CMD! Right after the great way it handles fullscreen and resizing!

    Also, since many people mention Alt only, it might just be that Ctrl gets added in Gnome since Alt + drag moves the window in Gnome...



  • @Onyx, @TwelveBaud, @JBert

    Alt + mouse isn't the same as being able to shuffle text around on keyboard. Is there the alternative for Alt+Shift+cursors (Alt+Ctrl on Windows)? Ctrl+ Left/Right with vertical cursor? Ctrl+D? "Find All" that creates a multi-selection? I'm not saying there isn't, but so far, I haven't seen it.

    @JBert said:

    Do you want to match the complete filename or just the extension? The latter is do-able.

    I know it's doable, but not easy. Also, extension only rule sucks. If I want to edit an .htaccess with syntax highlighting, I'm out of luck.



  • @cartman82 said:

    My problems with notepad++ are mostly that it keeps annoying me with updates

    This is my only gripe. Even worse, they stack update dialogs. If I forget to disable the update checker, I get two different dialogs with pretty much the same message at startup. Everything else about Notepad++ (that I use) is perfect.

    Also, Notepad++ has menus? I guess I've never ever used them for anything ever.



  • @boomzilla said:

    Like this one that opens a context menu. Then there's stuff that doesn't seem to do anything at all. Clear. I still have no idea what that (where NumLock would normally be) is supposed to do.

    Old-school Macs had "Clear" there because the numpad was a 10-key calculator, and calculators have a "Clear" button and it did exactly what you expected. And old Macs didn't have "numlock" because the entire concept of "numlock" is fucking stupid.

    Num Lock is one of those keys that exists merely so that when it's pressed by accident it makes your computer look broken. There's a surprisingly large amount of those keys.


  • BINNED

    @cartman82 said:

    Alt+Shift+cursors

    I just mashed keys and...

    WUT? I don't understand this, what is it doing? o.O

    Oh, wait, I get it... Acts really weird when moving up or down though, I'd expect it to select the first word in the line, not... this.


  • Fake News

    @cartman82 said:

    Ctrl+D?

    Hang on, are you talking about multiple cursors? That's something pioneered by Sublime, and so far Atom is one of the few contenders.



  • @cartman82 said:

    Is there the alternative for Alt+Shift+cursors
    Yes, it's AltShift←↑↓→. Seriously, try it.



  • @Gaska said:

    Only if you're using a shitty text editor. But even those support Shift+Tab.

    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.


  • BINNED

    @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.

    DAMN IT BLAKEY, STOP MAKING ME AGREE WITH YOU!

    Now I'm confused, which thread are we in? Oh, right, this is the one I agree with you completely. Boring... Now, where was the one with a CLI flamewar brewing...



  • @TwelveBaud said:

    Yes, it's AltShift←↑↓→. Seriously, try it.

    I see. Unless I'm missing something, it's useless. You can only use it to select a block of text. Once you let go of modifiers, it disappears.

    Here's a test.

    var x = {
      a: 1,
      second: 2,
      third: 3
    }
    

    Try converting this into:

    var x = [ "a", "second", "third"];
    

    In sublime (on Windows):

    1. Bring cursor to the left of 'a' (second line, column 2)
    2. Ctrl + Alt + Down Arrow x 2
    3. Type "
    4. Ctrl + Right Arrow
    5. Type "
    6. Shift + End
    7. Type ,
    8. Press Del twice
    9. Finish the editing normally

    I can do similar thing in JetBrains editors and, I'm sure, vim and emacs. Try the same in notepad++.


  • BINNED

    @cartman82 said:

    vim

    Ctrl+v for block select
    Shift+i to enter insert mode and still stay in block mode
    ... steps here ...
    Esc to finish

    Just for reference porpoises. And yes, the fact you need to use Shift+i instead of just i is stupid, IMHO.


  • Fake News

    @Onyx said:

    ... steps here ...

    Actual hard part left as an exercise to the reader?

    Vim doesn't do variable-width block selection, I think you need a macro for this (though there is likely more than one way to do it™).


  • BINNED

    @JBert said:

    Vim doesn't do variable-width block selection

    Pretty sure there is, it's just a different shortcut, got it mixed up with something... hold on...

    Nope, can't figure it out by guessing and too lazy for googling. Pretty sure I did it once by accident though :P



  • See :help characcterwise-visual, :help linewise-visual, and :help blockwise-visual. Or, equivalently, :help v, :help V, and :help CTRL-V

    Wait, variable-width. No. This looks like a regex problem.



  • @Onyx, @Jbert, @PleegWat

    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?


  • SockDev

    @Gaska said:

    Chill out. Both spaces and tabs are fine - as long as they're not mixed together. Because of that last bit, I'm spaces supporter - because if your line exceeds length limit, space-aligning looks nicer than double-indent or whatever you do with tabs.

    When the lead developer says, and I quote, 'use tabs of 8 spaces'...?


  • SockDev

    @PleegWat said:

    My trace logs can go into the gigabytes. Though vim dislikes them if they get over 1-2 gigs, and I switch to less instead.

    Naturally, I can par them down with grep first if needed. But windows users don't have that option now do they?

    Because no-one ever made grep for Windows? My tool of choice: http://www.baremetalsoft.com/baregrep/

    Also a big fan of their take on tail for Windows.



  • How about this tag-line.

    ##Command-line windows: When you want the worst of both worlds!


  • SockDev

    Given that I've as recently as yesterday been writing batch files to automate command line to work around PHP bugs on Windows... I'm already long part that particular circle of hell?

    Oh and I wrote said batch files in Notepad++ because it's better than PSPad. The other guy that worked on them did his stuff in vim because we can use whatever editing tools we choose.



  • @cartman82 said:

    @Onyx, @Jbert, @PleegWat

    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?

    What exactly is it that you're trying to do?



  • @Arantor said:

    Because no-one ever made grep for Windows? My tool of choice: http://www.baremetalsoft.com/baregrep/

    Also a big fan of their take on tail for Windows.

    I usually install msys on any Windows machine I use regularly. That gives you grep (and ls, rm, etc, etc...)



  • I usually install Interix on any Windows machine I use regularly. That gives you grep (and ls, rm, case-sensitive NTFS, exemption from any and all Win32 limits, ksh, etc, etc...)



  • @tar, he wants this:

    (Below from @cartman82 but discoquoting)
    Here's a test.

    var x = {
      a: 1,
      second: 2,
      third: 3
    }
    

    Try converting this into:

    var x = [ "a", "second", "third"];
    

  • SockDev

    <?php
    echo 'var x = ', json_encode(array_keys($x));
    


  • Why not just use a regex? :%s/\w\+: \(\w\+),/\1,/gc ought to work...


  • SockDev

    That's a little too exotic for the people I work with. I already get 'what is that?' when they see my command line window running PHPMD.


  • SockDev

    Now you have two problems.



  • That's why I said 'sounds like a regex problem'. Apparently that doesn't count.



  • I have many more than two problems! :D



  • @PleegWat said:

    That's why I said 'sounds like a regex problem'. Apparently that doesn't count.

    Oh I see, it's that shit where you solve someone's problem for them and then they came back with "Oh, I don't like that solution. I'll just pretend it doesn't exist..."



  • @tar, @Arantor

    It's not a coding challenge, the point is to edit that as text.

    @tar, you can do regex in any old text editor, I expected better from vim. In fact I just assumed it would be a piece of cake and require even less keystrokes than sublime.

    I guess not.



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


  • BINNED

    @cartman82 said:

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

    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.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.