News for hackers. Stuff that matters.
Re:Vim Anti-Patterns by sdegutis on Wednesday October 05, 2016 @10:41AM (#12644170)
> "If you have to move more than a couple of lines, moving one line at a time by holding down j or k is inefficient."

This very point is actually why I moved from Vim to Emacs years ago. After mastering Vim, I realized that Vim strongly encourages you to think a little too much about exactly how to get there or do that thing in the fewest keystrokes, and that it's incompatible with muscle memory. Even years later, I still had to think too much about it. Whereas in Emacs I can just use basic character/word/line-based movements and let my muscle memory do its thing while I let my brain focus on the code itself instead of how to use the text editor.

Re:Vim Anti-Patterns by plgs on Wednesday October 05, 2016 @10:55AM (#12644306)
Honest question: How does Emacs help with this particular problem ?

I feel like with every editor, it involves repeatedly hitting J, Ctrl+N or down arrow, which is inefficient. Do you have a way to get to a particular line that does not force you to think too much about how to get there ?

Re:Vim Anti-Patterns by qwertyuiop924 on Wednesday October 05, 2016 @11:40AM (#12644787)
Of course we do: You can jump by searching for line contents with C-s, you can do an operation a certain number of times with M-<number> <operation>, and do an operation four times with C-u <operation>, which chains, so you can do an operation 16 times with C-u C-u <operation>.

If you want to jump to a specific line number, you can use M-g M-g <number>, or (because C-u also provides numerical arguments) C-u <number> M-g M-g.

Finally, many motion commands set the mark, so you can use C-x C-x to return to where you were and select all text between your previous and current locations.

Oh, and if you want something even better, you can use C-` to jump to the location of compiler error if you use M-x compile, you can use ag.el or helm-ag for ag integration, Ace-Jump, which is similar to EasyMotion, built-in exuberant ctags integration (and a built-in ctags clone, etags), packages for cscope integration (if you're using C), and fiinally semantic, which provides a variety of parser-based tooling if it's supported by your language.

But you can also just use C-n, etc. and we won't judge you for it.

Re:Vim Anti-Patterns by sdegutis on Wednesday October 05, 2016 @12:11PM (#12645124)
> "But you can also just use C-n, etc. and we won't judge you for it."

This is probably the biggest selling point of the Emacs community. They're not going to try to guilt or shame you into using more efficient or more advanced commands. If C-n works for you, use it!

Re:Vim Anti-Patterns by qwertyuiop924 on Wednesday October 05, 2016 @03:03PM (#12646748)
Of course. We can't judge you. Your configuration and setup is likely so different that unless we meet up in person, it's impossible to tell who is more efficient.
Re:Vim Anti-Patterns by minitech on Wednesday October 05, 2016 @04:19PM (#12647445)
Wait, how’s this different from Vim? You can use :<number> to go to a line and C-o to return to where you were.
Re:Vim Anti-Patterns by qwertyuiop924 on Wednesday October 05, 2016 @04:51PM (#12647736)
It's really not different, except that we have more, better options for how to go about it. The difference is, you can just use C-n, and nobody will complain that you're doing it wrong. Well, not too much, anyways.
Re:Vim Anti-Patterns by minitech on Wednesday October 05, 2016 @05:04PM (#12647867)
Sounds like the options are the same. Note that it isn’t some kind of Vim standard that j shouldn’t be used repeatedly, just this author’s opinion. I do it all the time.
Re:Vim Anti-Patterns by qwertyuiop924 on Wednesday October 05, 2016 @05:44PM (#12648189)
Does vim have the ability to jump to compiler errors, ctags integration, cscope integration, and integration with sourcecode parser based tooling?
Re:Vim Anti-Patterns by sdegutis on Wednesday October 05, 2016 @11:19AM (#12644562)
> How does Emacs help with this particular problem?

What, inefficiency? Inefficiency wasn't the problem. The problem was having to focus too much of my mind on how to use the editor. Muscle memory is invaluable, and Vim just doesn't let my muscle memory take over if I keep having to think about what's the most "efficient" way to move around or change text. Emacs lets my muscle memory take over easily. I just hit C-n or M-S-] a lot. It's inefficient, sure. But who cares? I never realize I'm doing it, and I never feel blocked having to wait until I get to the line I want to.

Re:Vim Anti-Patterns by u801e on Wednesday October 05, 2016 @11:26PM (#12650021)
> The problem was having to focus too much of my mind on how to use the editor. Muscle memory is invaluable, and Vim just doesn't let my muscle memory take over if I keep having to think about what's the most "efficient" way to move around or change text.

IME, you do develop muscle memory in terms of using more "efficient" ways of navigation and text manipulation after using vim for a while. I guess it's sort of like learning how to drive a vehicle equipped with a manual transmission. At first, you're thinking more about how to shift through the gears and use the clutch. After a while, you don't really think about it too much while you're still doing it. After driving a bit longer, you start to get a feel about which gear to choose for a given traffic situation.

So, similarly, you get a feel about which keybinding to use to change certain types of text or do certain movements without having to think too much about it.

Re:Vim Anti-Patterns by aidenn0 on Wednesday October 05, 2016 @12:01PM (#12645014)
Normal vim users aren't thinking about the most efficient way to perform an edit, but rather just go with muscle memory. Said vim users also don't write blog articles on how to be more efficient with vim.
Re:Vim Anti-Patterns by sdegutis on Wednesday October 05, 2016 @12:09PM (#12645104)
Well after 5 years of using Vim, the muscle memory for more efficient operations never kicked in. I was either holding "h" and "l" to move around, or I was consciously thinking of the more efficient combined operations like "f.ce.com^[". And that conscious thinking was very distracting from the actual code I was editing.
Re:Vim Anti-Patterns by disease on Wednesday October 05, 2016 @02:37PM (#12646534)
I used vim for everyday use for almost ten years before I realized that navigating around with the keyboard would never be as good as clicking a mouse. All the mental overhead of trying to be efficient with vim, for me at least, ended up being a bit of a false oasis.

I happily switched to Sublime for two years and then VS Code. I still use emacs with Clojure though.

Re:Vim Anti-Patterns by sdegutis on Wednesday October 05, 2016 @02:58PM (#12646704)
Similar story here. I use IntelliJ for Java and Emacs for Clojure. We're porting our codebase from Clojure to Java at work, so soon it'll all be IntelliJ, which will be pretty sweet. I do kinda miss Paredit, but IntelliJ makes up for it with lots of other pretty sweet features.
Re:Vim Anti-Patterns by slgeorge on Thursday October 06, 2016 @09:07AM (#12652084)
Out of interest did you try using the Vim plugins for Clojure?

I'm only playing, but found a good set-up with vim-fireplace; vim-clojure-highlight; vim-sexp; Vim-sexp-mappings-for-regular-people; vim-surround and luochen1990/rainbow

Re:Vim Anti-Patterns by qwertyuiop924 on Wednesday October 05, 2016 @02:57PM (#12646695)
Emacs is unbeatable for editing lisp code. Geiser, Quack, SLIME, and CIDR are all excellent.
Re:Vim Anti-Patterns by Ianvdl on Wednesday October 05, 2016 @12:41PM (#12645448)
What prevents you from using vim inefficiently in the same manner?
Re:Vim Anti-Patterns by to3m on Wednesday October 05, 2016 @12:48PM (#12645519)
1. place hand on mouse

2. move mouse cursor to desired position

3. click mouse

If you're just looking to put the cursor somewhere you can see, this is actually quite quick.

Re:Vim Anti-Patterns by tgb on Wednesday October 05, 2016 @04:20PM (#12647462)
:set mouse=a
Re:Vim Anti-Patterns by to3m on Wednesday October 05, 2016 @10:53AM (#12644287)
Just a question of practice, I found. I was a regular vim user in the past, and this was my criticism of in when first starting out - but after a while I found myself unthinkingly coming up with surprisingly complicated sequences of keypresses. It's possible to get very good at subconsciously sizing up editing operations.

These days I use emacs, and I pretty much always move the cursor using the mouse.

Re:Vim Anti-Patterns by sevensor on Wednesday October 05, 2016 @11:00AM (#12644349)
While I use j and k a lot for local moves, for bigger jumps I almost always use other means: jumping to a mark, searching for a string, :123 to jump to a line, gg and G to go to the start and end. Or, less often, I fold and navigate around the folds, although I'm not a big fold user. I very rarely hit hjkl more than ten times in a row.
Re:Vim Anti-Patterns by sdegutis on Wednesday October 05, 2016 @11:20AM (#12644578)
Well I got really good at it after like 5 years of using it, and that muscle memory never kicked in for me. So maybe it's possible that it can be done, just not by everyone?
Re:Vim Anti-Patterns by xemdetia on Wednesday October 05, 2016 @10:51AM (#12644265)
As an Emacs user I want to plug ace-jump-mode to move around the viewable part of the buffer more efficiently than many of the commands mentioned in the OP's post.

1. look at character you want to go to 2. M-x ace-jump-mode (I have this bound to F9) 3. Hit key for the character you want to go to 4. All instances of them are rewritten in the buffer with a coloured character. 5. Hit the coloured character you are looking at.

The trick is to just look at where you want to go and touch type the rest. Even on very large monitors with dense data (I find this invaluable if I am going through an minimized HTML blob or a plaintext database dump) this can turn any point to be 3 keystrokes away. Cursor + search forward doesn't work if there is a lot of duplicate text around where you want to go, like a string of five .set* methods and you are trying to kill the third one

Re:Vim Anti-Patterns by qwertyuiop924 on Wednesday October 05, 2016 @12:00PM (#12645004)
I have got to try AceJump one of these days...
Re:Vim Anti-Patterns by mrkgnao on Thursday October 06, 2016 @04:11AM (#12650916)
This reminds me of easymotion.
Re:Vim Anti-Patterns by tmsbrg on Wednesday October 05, 2016 @12:19PM (#12645222)
Personally I think some people just go too far with that kind of /efficient movement/ thinking. There's nothing wrong with pressing j or k a few times, and I agree it's a waste of brain energy to think hard about how to get wherever. (I also think hjkl vs arrow keys is overrated, though I've learned to use hjkl)

The only commands I use to move vertically in vim are j, k, /, ?, ctrl-d, ctrl-u. And sometimes I just get the mouse and click.