News for hackers. Stuff that matters.
Re:Seven habits of effective text editing (2000) by jimmaswell on Monday October 23, 2017 @09:46AM (#15533095)
I didn't mean just blocks of code that would be recognized as a paragraph or are fully enclosed in brackets or anything like that. I mean moving some lines around possibly within the same function, which may or may not have multiple newlines between some of them, and have no lexically distinctive property aside from being the lines you want.
Re:Seven habits of effective text editing (2000) by jonahx on Monday October 23, 2017 @10:09AM (#15533252)
I'd make a few counterpoints there:

1. Even in those situations, I believe a veteran vim user would still beat someone using a mouse.

2. That said, the situation you describe is relatively rare: when coding you typically will be addressing blocks of text defined as functions; sharing an indent level ("ii" selects these); or otherwise selectable by vim in 2-3 keystrokes.

3. Even when that's not the case and the vim selection takes, say, 5 or 6 keystrokes, it has the advantage that your fingers never left the home row, so there is no wasted time "resetting."

4. Just as a tip: doing a "/" search for 2-3 characters after making your visual selection is typically enough to define your block, and will often be faster (and less of a cognitive distraction) than trying to eyeball or count the number of lines and doing a "10j" motion or similar.

Re:Seven habits of effective text editing (2000) by stabbles on Monday October 23, 2017 @10:35AM (#15533440)
> sharing an indent level ("ii" selects these)

That doesn't seem to work. Am I missing something?

Re:Seven habits of effective text editing (2000) by jonahx on Monday October 23, 2017 @10:53AM (#15533588)
I'd forgotten that I get this feature from a plugin:

https://github.com/michaeljsmith/vim-indent-object

Re:Seven habits of effective text editing (2000) by xyzzy_plugh on Monday October 23, 2017 @10:01PM (#15538662)
I've been eyeballing the number of lines (or characters) long enough that I am correct more often than not.

Also, relative line numbering changed my life.

Re:Seven habits of effective text editing (2000) by hellofunk on Monday October 23, 2017 @09:54AM (#15533149)
I used to share your sentiment but kept going with vim for a year, and now I'm spoiled. Any time for some reason I am forced to use a GUI and a mouse, everything just feels so slow to me now.
Re:Seven habits of effective text editing (2000) by btschaegg on Tuesday October 24, 2017 @02:17AM (#15539620)
Same here. Even if I'm forced to work with non-Vim tools (Visual Studio for example) using their often incomplete Vim-emulations makes lightyears of a difference.

If I had to "criticize" one of Vim's concepts, it would be its way of overriding registers in very unintuitive situations, but I'm certain I'll get used to that, too. When you're aware of it, it's simple to avoid using "_ first.

Edit: OTOH, selecting a piece of text and replacing it with p is quite irritating: The 0 register will still contain its original data, but " will contain the replaced text. I am not aware of how to disable this effect ("_p will paste from the black hole register, which doesn't help in this case).

Re:Seven habits of effective text editing (2000) by matthewaveryusa on Monday October 23, 2017 @10:25AM (#15533356)
put a marker at the begining of what you want to cut (mb) b is an arbitrary character but I use b becaues b = begin. find the end of the block with search, or jkl; or whatever. mark the end of the block (me) e is for end. now type `b, that will bring you back to the start. type v, that puts you in visual mode. type `e, that selects your text from begin to end. x to cut it.

so all in all it's mb<search>me`bv`ex

now if your say you can search your text faster with your mouse than with keystrokes you have a different problem: you don't know how to use the search features in vim efficiently.*

I think it's nearly impossible to be faster with a mouse than a keyboard when it comes to search.

*and yes, to be efficient at it there's a 2 month learning curve that pays dividends over the next 30 years of your programming career -- it's up to you if you think it's worth the investment or not. Use it or lose it, if you don't make an effort you'll stay at your local maximum.

Re:Seven habits of effective text editing (2000) by jonahx on Monday October 23, 2017 @10:31AM (#15533406)
> so all in all it's mb<search>me`bv`ex

why not just?

    v<search>x
Re:Seven habits of effective text editing (2000) by matthewaveryusa on Monday October 23, 2017 @10:55AM (#15533614)
Just another suggestion. sometimes visual mode is overwhelming, or you don't want to be in it while your search for the end of the selection without being sure where it is. Another thing is if you start with line visual mode (V), and then you end up not wanting line selection the markers help you out -- it's a finer-grained set of commands that's a bit more flexible and a bit less efficient.
Re:Seven habits of effective text editing (2000) by mbag on Monday October 23, 2017 @09:58AM (#15533172)
Or switch to Visual Line mode (<shift>+v) to select desired lines and you don't need to count how many lines to delete/yank.

Another useful visual mode is Visual Block (<ctrl>+v), for deleting/yanking, replacing block across multiple lines.

Re:Seven habits of effective text editing (2000) by tgb on Monday October 23, 2017 @10:03AM (#15533210)
That's exactly what jimmaswell suggested he didn't like, though.
Re:Seven habits of effective text editing (2000) by mbag on Monday October 23, 2017 @10:51AM (#15533568)
I see, I thought he had problem with counting line numbers to delete :)
Re:Seven habits of effective text editing (2000) by rco8786 on Monday October 23, 2017 @09:51AM (#15533133)
It’s still just a few keystrokes.. 10dd 5j p. Take 10 lines, move down 5 lines, paste those 10 lines. With relative line numbers in the gutter there’s no counting involved either. The whole thing is faster than even just reaching for the mouse.
Re:Seven habits of effective text editing (2000) by throwawayReply on Monday October 23, 2017 @10:31AM (#15533402)
But cursors don't imply mice.

With cursors you just hold shift and use down-arrows to (visually) select the lines you want. Add in Ctrl and you can move word-boundaries, add home-end and you can do beginning/end lines / pages too.

The whole thing is still quicker than vi but with the added benefits of getting much more visual feedback on what is happening and the ability to use the mouse to also quickly select things.

Re:Seven habits of effective text editing (2000) by smelterdemon on Monday October 23, 2017 @12:59PM (#15534674)
Sounds like Visual mode
Re:Seven habits of effective text editing (2000) by makapuf on Monday October 23, 2017 @10:51AM (#15533567)
Add to that by example sublime text Ctrl shift up to move the selection up one line. Really hope other editors would just take sublime key mappings
Re:Seven habits of effective text editing (2000) by aenda on Tuesday October 24, 2017 @12:17AM (#15539172)
selecting something and hitting dP (potentially kdP) will do the same thing in vim
Re:Seven habits of effective text editing (2000) by throwawayReply on Tuesday October 24, 2017 @04:53AM (#15540170)
In sublime text you don't need to select anything, ctrl+up/down will move the whole current line up/down.
Re:Seven habits of effective text editing (2000) by criddell on Monday October 23, 2017 @10:03AM (#15533204)
How far away is your mouse?
Re:Seven habits of effective text editing (2000) by jonahx on Monday October 23, 2017 @10:23AM (#15533346)
As close as you like. Mouse movements are much more finicky than keyboard ones -- they require a physical precision (seeking, alignment, selection) that keyboard movements don't. And if you never leave the keyboard, you don't have to return to the keyboard to continue your typing. I'm confident even a moderately skilled touch typist familiar with vim would outperform someone switching to the mouse on average for these kinds of tasks.
Re:Seven habits of effective text editing (2000) by geofft on Monday October 23, 2017 @10:32AM (#15533413)
I would be very interested to a) see this claim tested b) see if it makes a difference in productivity. (Most of what makes me slow at work is trying to understand technical problems, not trying to find parts of text in my editor.)
Re:Seven habits of effective text editing (2000) by shadowfiend on Monday October 23, 2017 @12:21PM (#15534335)
While not a direct test, there's prior research into the fact that folks who use keyboard shortcuts think they're faster than their mousing counterparts---and are wrong:

http://www.asktog.com/TOI/toi06KeyboardVMouse1.html

> We’ve done a cool $50 million of R & D on the Apple Human Interface. We discovered, among other things, two pertinent facts:

> - Test subjects consistently report that keyboarding is faster than mousing.

> - The stopwatch consistently proves mousing is faster than keyboarding.

(PS and caveat emptor: it's now 30 years since that study was done. Also, I personally firmly enjoy my vim. I just try to stick to liking it because I like it, not because it makes me an uberuser. An uberuser will probably be an uberuser no matter what.)

Re:Seven habits of effective text editing (2000) by vthriller on Monday October 23, 2017 @06:16PM (#15537392)
Ugh, I don't know, a lot of things could skew that result, from font/button sizes (it's hard to miss if you could only fit 5 lines of text on your screen) to insane shortcuts to memorize (I mean c'mon, ⌘-⇧-4 to take a screenshot? There's a line or two about that at the link, but it's presented like inferior and ambiguous combinations are the only one that UI/UX folks can come up with) to ergonomics of the input devices themselves (some cannot stand chiclet keyboards, some can be really productive with trackpoints—sure, this doesn't sound anything like pre-1989 Apple but you get the idea) to even cursor speed/acceleration curve settings. That being said, I'd like to see some details on that R&D.
Re:Seven habits of effective text editing (2000) by e12e on Monday October 23, 2017 @03:41PM (#15536303)
I still think this might hold true. But for me mouse (and touchpads, trackpoints) trigger repetitive stress syndrome - so acme isn't really an alternative - yet.

But I have some hope for merging the ideas of acme with proper touch screens/digitizers.

Re:Seven habits of effective text editing (2000) by tincholio on Tuesday October 24, 2017 @10:27AM (#15541772)
Also, the poor experimental design and lack of peer review about casts some doubt, really.
Re:Seven habits of effective text editing (2000) by jonahx on Monday October 23, 2017 @10:59AM (#15533637)
> I would be very interested to a) see this claim tested

I would too. But I'd be willing to wager on the results beforehand.

> b) see if it makes a difference in productivity. (Most of what makes me slow at work is trying to understand technical problems, not trying to find parts of text in my editor.)

There's no doubt that things like understanding technical problems, avoiding procrastination, and many non-technical factors are the high-order bits of productivity.

That said, the context of this conversation is text-editor optimization. Also, I think the true benefit of an optimized text editor isn't in raw time savings but in increased flow and just the joy of having a tool that feels like the extension of your mind, rather than something your mind works around.

Re:Seven habits of effective text editing (2000) by btschaegg on Tuesday October 24, 2017 @03:41AM (#15539889)
> Also, I think the true benefit of an optimized text editor isn't in raw time savings but in increased flow and just the joy of having a tool that feels like the extension of your mind, rather than something your mind works around.

My thoughts exactly (although mine might not have been worded that well :) ).

Vim-bindings are like a REPL, but on a different level. If you compare a REPL to a loop of "save, compile, run, enter passwords, wait for a specific event to trigger", you might get a grasp of what a Vim-enthusiast gets out of the editor. They've fixed the thing to fix and moved on while you're still trying to find out where your mouse movement went.

That might sound a bit exaggerated, but for the skeptics, I propose an experiment: Switch your keyboard to a different language (say Turkish, if you're very brave) and try to code for a couple of minutes. I do that regularly (my colleagues don't use the same layout as me), and I'd wager it's about the same level of annoyance as not being able to use Vim-bindings if you're used to them.

I'm not saying that there aren't other effective ways of editing text, I'm merely finding that the defaults aren't very good.

Re:Seven habits of effective text editing (2000) by criddell on Monday October 23, 2017 @11:25AM (#15533844)
> Also, I think the true benefit of an optimized text editor isn't in raw time savings but in increased flow and just the joy of having a tool that feels like the extension of your mind, rather than something your mind works around.

I couldn't agree more. For me, that's working with a Logitech Anywhere MX mouse in Sublime Text. I imagine how I want the text on screen to be transformed and it just happens without conscious thought.

Re:Seven habits of effective text editing (2000) by zastavka on Monday October 23, 2017 @02:08PM (#15535440)
Anything special about that particular mouse that makes it good for editing with ST?
Re:Seven habits of effective text editing (2000) by criddell on Monday October 23, 2017 @02:16PM (#15535508)
No. It's just the mouse I've been using for a long time now. It's small, I'm used to how it tracks and accelerates, it fits my hand, and you can disengage the click mechanism on the scroll wheel to spin it freely.

My big complaint is that the buttons eventually start to fail. Single clicks will sometimes register as double clicks and click-drag operations start to drop early.

Re:Seven habits of effective text editing (2000) by Spooky23 on Monday October 23, 2017 @04:06PM (#15536513)
It depends on how much you do the activity.

When I was a DBA, I did all sorts of data normalization stuff, and the Unix pipeline of tools (vim, sed, awk, some perl) was necessary and I was adept at it. Today, I don't do it that often, and it's quicker to just use Excel or whatever for slicing and dicing. It's not worth the overhead to save 10 minutes of manual tasking.

You'd see this when you did green screen to web transformations in enterprise projects. Training would 1/10 the effort, and knowledge based processes would be faster, but the new people would be alot slower than the veteran keyboard operators.

Re:Seven habits of effective text editing (2000) by criddell on Monday October 23, 2017 @10:55AM (#15533611)
> Most of what makes me slow at work is trying to understand technical problems

That's me too. I spend a lot of time each day reading and that's a lot of scrolling with my mouse and ctrl-clicking on works to jump to definitions or declarations. Text editing speed is definitely not a bottleneck for me.

Re:Seven habits of effective text editing (2000) by chucky_z on Monday October 23, 2017 @12:38PM (#15534489)
Have you tried a trackball mouse? That was the magic 'ah-ha' moment for me. I haven't used a normal mouse (at work) in probably 6 years or so. I find in speed it is trackball + kb > kb-only > normal mouse + kb.
Re:Seven habits of effective text editing (2000) by adrianN on Monday October 23, 2017 @09:53AM (#15533145)
I'm not super good with movements myself, so I just use visual mode and the movements I know to select what I want. It doesn't take me longer than reaching for the mouse and moving it around most of the time.