Live data from Hacker News

Vim Anti-Patterns

sanctum.geek.nz

171–180 of 249 posts

Re: Vim Anti-Patterns

#171
post #123

Earlier quoted context omitted.

I have two tricks for better movement, add the following to your .vimrc: " for scrolling up and down quickly nnoremap J 7j nnoremap K 7k vnoremap J 7j vnoremap K 7k and the second (which requires a third party plugin): " easymotion allows us to jump to all places that could have been reached by " (w in this case), and the bd- indicates we want to search backwards too. nmap f (easymotion-bd-w) vmap f (easymotion-bd-w)…

Have you tried using :relativenumber? You still have to type eg 12j or whatever but at least vim does the counting for you. If so, can you share why you like easymotion more? Thanks!

Yes, I use : very occasionally, mainly if I know I need to edit a certain line number in a file and just opened that file. But for regular use the time to type in a line number is just too long since I can't touch type numbers very quickly (when do we ever get practice typing in long numbers after all?).

I use easymotion because it's the fastest way to go from my eye spotting something on the screen to my cursor being there. It's two button presses consistently, you can't really beat that with some combination like 5j$2b, especially since that combo is different every damn time.

Re: Vim Anti-Patterns

#172

Earlier quoted context omitted.

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.

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.

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

#173
post #151

Not trying to start a flame war here, but I in recent few years I am seeing Vim being more popular, and I feel it adoption in terms of younger developers (those who weren't programming when original Vi was around) grows. (Ok, please forget about GUI editors, they have their audience, and I am not comparing any of those facts to them) I used Vim for 3 years, and found philosophy and implementation of modal editing ama…

I’m primarily a Vim user, but I use Emacs for some stuff like Common Lisp programming, Org mode, etc. But what I sometimes miss from Vim is the filtering with external commands. For example if I want to pipe my file through awk, I can just do :%!awk ' ' Does Emacs have something like this out of the box?

of course it does, as said by nemoniac! Here: https://www.emacswiki.org/emacs/ExecuteExternalCommand

Re: Vim Anti-Patterns

#174

Earlier quoted context omitted.

> I have no idea how people learn Vim LOL, I felt the same way about emacs when I tried to force myself to use it. Interesting that you point out that "the scripting is awful" - my sense after a year of using emacs full time was that the _only_ way to use emacs is to learn to script/reprogram it. If you don't mind my asking - how _did_ you learn emacs? Were you a lisp programmer to start with? Or did you learn it in…

Yeah, scripting a huge focus in emacs: they say it's a scripting environment that happens to have a text editor embedded in it. I don't know who "they" are, but they're quite perceptive. Some lisp experience (especially CL) can help with learning elisp, but it's entirely possible to do so without it. The process of learning emacs is roughly this: -Launch emacs -Run through the tutorial -Learn the shortcuts and gain g…

Haha, you described many things perfectly! But what drove me the most towards emacs despite being suitable for FP, huge amount of tweaking and customizability it provides. And it felt much better doing it in Elisp than Vimscript. Everything has it's good and bad sides, that is normal imho. But really nice comment! :)

Re: Vim Anti-Patterns

#175

I never got into the habit of using { and }. I just use H M L (high/medium/low) to get approximately in the right part of the screen, then go line-by-line. You can also do 5H or 10L to get "5 lines from the top" or "10 lines from the bottom". I make pretty good use of vim features, but I like to mix some sloppiness with the precision. I don't often count things before typing commands, because that breaks the second-n…

I have two tricks for better movement, add the following to your .vimrc: " for scrolling up and down quickly nnoremap J 7j nnoremap K 7k vnoremap J 7j vnoremap K 7k and the second (which requires a third party plugin): " easymotion allows us to jump to all places that could have been reached by " (w in this case), and the bd- indicates we want to search backwards too. nmap f (easymotion-bd-w) vmap f (easymotion-bd-w)…

I have some similar mappings in mine. Capital J and K go up or down 4 lines, capital H and L move by words instead of characters. It feels like holding down the button to run instead of walk in Super Mario Bros.

Re: Vim Anti-Patterns

#176
post #65

Earlier quoted context omitted.

The advantage of c2w is that it combines everything in a repeatable (using .) operation.

and so does v2ec

It's not the same. That will only repeat the change of the number of characters of the length of those 2 words. c2w, when repeated, will change 2 words, no matter how long the words are.

For example:

    This is a string of text.
    This is a string of text.
If the cursor is at the "i" of "is" on line 2, and you type v2echello, you will have:

    This is a string of text.
    This hello string of text.
If you move the cursor to the "s" of "string" on the first line, and press ".", you will get:

    This is a hellong of text.
    This hello string of text.
However, if you had used c2w, it would have replaced "string of" with "hello" like so:

    This is a hello text.
    This hello string of text.
Visual mode is lossy in terms of text objects. It only remembers counts of character movements, that's why it replaced 4 characters with "hello" instead of replacing 2 words with "hello".

Re: Vim Anti-Patterns

#177

Earlier quoted context omitted.

horrible example on my part but in every day editors to delete 2 word backwards it would either be (what i'm used to is shift+ctrl then left arrow key 2 times + delete or start typing to change. Someone else mentioned ctrl+ works just as fast. I probably should have given a much better case. However, my point still stands that pressing db or d2b is within home row or as other mentioned db. and then how ever many '.'…

Home row? I understand you completely: Ctrl+bbdd does what you asked for. Vim's d2b actually moves far away from the home row (note the "2")! Not wanting to do the finger acrobatics? I'm even more with you here: I remapped Ctrl and Alt to be just next to space, and space to serve both as space and shift . And, to point out that vim absolutely requires pinky acrobatics all the time with its reliance on : and ESC , so…

Esc is the bad one in my view, but I never press it at all while using vim. This comes down to two factors:

- I use "jk", typed quickly, to exit insert mode. Most vim users I know use either this or "jj".

- I have rebound Caps Lock to Ctrl, and in the few situations where I would otherwise hit Esc, I hit Ctrl-C, which causes much less strain. (This is technically different than Esc, but the difference doesn't usually matter; if it's necessary, Ctrl-[ functions exactly the same as Esc.)

Re: Vim Anti-Patterns

#178

I never got into the habit of using { and }. I just use H M L (high/medium/low) to get approximately in the right part of the screen, then go line-by-line. You can also do 5H or 10L to get "5 lines from the top" or "10 lines from the bottom". I make pretty good use of vim features, but I like to mix some sloppiness with the precision. I don't often count things before typing commands, because that breaks the second-n…

I have two tricks for better movement, add the following to your .vimrc: " for scrolling up and down quickly nnoremap J 7j nnoremap K 7k vnoremap J 7j vnoremap K 7k and the second (which requires a third party plugin): " easymotion allows us to jump to all places that could have been reached by " (w in this case), and the bd- indicates we want to search backwards too. nmap f (easymotion-bd-w) vmap f (easymotion-bd-w)…

Ahg, no I couldn't do that, I need to keep J as Join lines. That's pretty useful to me. Kinda the inverse of gq.

Re: Vim Anti-Patterns

#179

Not trying to start a flame war here, but I in recent few years I am seeing Vim being more popular, and I feel it adoption in terms of younger developers (those who weren't programming when original Vi was around) grows. (Ok, please forget about GUI editors, they have their audience, and I am not comparing any of those facts to them) I used Vim for 3 years, and found philosophy and implementation of modal editing ama…

> I tried EVIL mode, and it is amazing, but something just felt wrong using it inside Emacs

For me the "feels wrong" is that vim is always just a little bit snappier than emacs. If you gave me a borderless window with no branding and only let me type vi commands I bet I could tell vim from emacs 9/10 times.

I used emacs exclusively for > 20 years and just recently began to transition to vim to save my tendons. It's amazing that so many of the verb-noun command constructs are still wired in to my brain stem.

Re: Vim Anti-Patterns

#180

I never got into the habit of using { and }. I just use H M L (high/medium/low) to get approximately in the right part of the screen, then go line-by-line. You can also do 5H or 10L to get "5 lines from the top" or "10 lines from the bottom". I make pretty good use of vim features, but I like to mix some sloppiness with the precision. I don't often count things before typing commands, because that breaks the second-n…

I share some of your sentiments. I find that I so frequently want to go the first and last non-whitespace characters in a line that I remapped H to go to first non-whitespace character and L to go to the last. I think of these as "linewise-h" and "linewise-l", which almost fits with vim's other conventions. Then I substitute ctrl-d and ctrl-u to go up or down by half-screens. I'll also note that although I do also fr…

I think ^ goes the the first non-empty character on the line already. Think of it like the regex. Then 0 (zero) goes to column 0.
Post reply on HN