Live data from Hacker News

To Master Vim, Use It Like Language

danielmiessler.com

81–90 of 124 posts

Re: To Master Vim, Use It Like Language

#81

Learning vim is easy, I've done it a thousand times! (As Mark Twain might say) This time around I've been keeping a list of the stuff I miss from my usual workflow. Here's two of the most maddening: 1. Searching for literal text. Is there a way to avoid having to manually escape special characters? 2. Maintaining cursor position when scrolling. Maybe I want to go look at another part of the file and come back. How ca…

2. Ctrl+o will bring you back to previous locations in many cases (e.g. after a search).

Re: To Master Vim, Use It Like Language

#82
post #4

Vim is a regular expression system hooked to a 1970s user interface. If you need to apply regular expressions to text files, vim is useful. I used vi to write code for years, but that was decades ago. There's been some progress since the 1970s.

That's just not what vim is... I don't even really know where to begin, you're just flat out wrong. I'd say you're confusing vim with something else, but I don't even know what else fits that description.

It is a true if disingenuously narrow-sighted description of the origins of vi as a visual interface to ex, a regex-based line-editor and descendant of ed. Even the ascetic ed, however, cannot be reduced to a "regular expression system." All the more is it untrue to claim that vi added nothing but a "user interface" to ex. (As if `dib` and `ct;` and `gqap` and `zf` and `gj` were so effortless in a line-editor!) That is to say nothing of the (admittedly clumsy) scriptability of vim.

Even if you agree with vim's approach to modal editing and object motions, there is plenty bad to be said about it in light of some of the tools we have available to us today. But humble origins do not always lead on to humble ends. There is no use in calling a book bad and giving as your reason that it was once pulp. It would be just as unhelpful to call the Lisps of today slow, and to use as your crutch the old adage that "LISP programmers know the value of everything and the cost of nothing."[1] As GP said, "There's been some progress since the 1970s."

[1] https://en.wikiquote.org/wiki/Alan_Perlis#Epigrams_on_Progra...

Re: To Master Vim, Use It Like Language

#83

This article is well written, but it has nothing to do with mastering Vim. It goes no further than running "vimtutor" at the command line. It has all the same tips and shortcuts as any other vanilla Vim tutorial. This is a common problem among Vim articles and tutorials. Authors title them as if it will give you Vim mastery, but instead it only offers the basics. Mastering Vim means going beyond vanilla movements and…

Article author here.

The irony in your comment is that I recommend Drew's book in the primer, and Drew has recommended this primer as well.

Maybe they're both good ways to learn Vim.

Re: To Master Vim, Use It Like Language

#84
post #81

Learning vim is easy, I've done it a thousand times! (As Mark Twain might say) This time around I've been keeping a list of the stuff I miss from my usual workflow. Here's two of the most maddening: 1. Searching for literal text. Is there a way to avoid having to manually escape special characters? 2. Maintaining cursor position when scrolling. Maybe I want to go look at another part of the file and come back. How ca…

2. Ctrl+o will bring you back to previous locations in many cases (e.g. after a search).

Assuming the stack grows up, ctrl+o moves you down the stack and ctrl-i moves you back up the stack. Pushing occurs on certain evens like searching and using marks. iirc, popping occurs when you push something onto the jump stack when you aren't at the top and the old (ctrl-i) is replaced by the new current location.

Re: To Master Vim, Use It Like Language

#85
post #3

> inoremap jk Using two keystrokes instead of ESC to leave insert mode is definitely a personal preference and not necessarily more efficient or comfortable.

Way more useful (for me anyway) is mapping Capslock to ESC. It works with any vi anywhere as long as you are using your main machine to connect. Also with inoremap don't you have to wait for the letter j to show up until you type your next character? That would drive me crazy. Edit now that I have actually looked at the article: Yes, you can map it to Control but for me it's an awkward place to put a modifier. What i…

I have this too, but it can be infuriating when:

* I have to quickly explain something on my colleagues machine. * A colleague wants to show me something on my machine.

The `` is, I daresay, one of the most ingrained keys when operating a computer. When you keep mistyping it, levels of stress will go up.

Re: To Master Vim, Use It Like Language

#86

Learning vim is easy, I've done it a thousand times! (As Mark Twain might say) This time around I've been keeping a list of the stuff I miss from my usual workflow. Here's two of the most maddening: 1. Searching for literal text. Is there a way to avoid having to manually escape special characters? 2. Maintaining cursor position when scrolling. Maybe I want to go look at another part of the file and come back. How ca…

1. /\Vliteral search 2. C-e and C-y as long as the cursor position doesn't move out of the visible area

[deleted]

Re: To Master Vim, Use It Like Language

#87

This article is well written, but it has nothing to do with mastering Vim. It goes no further than running "vimtutor" at the command line. It has all the same tips and shortcuts as any other vanilla Vim tutorial. This is a common problem among Vim articles and tutorials. Authors title them as if it will give you Vim mastery, but instead it only offers the basics. Mastering Vim means going beyond vanilla movements and…

[deleted]

Re: To Master Vim, Use It Like Language

#88

Learning vim is easy, I've done it a thousand times! (As Mark Twain might say) This time around I've been keeping a list of the stuff I miss from my usual workflow. Here's two of the most maddening: 1. Searching for literal text. Is there a way to avoid having to manually escape special characters? 2. Maintaining cursor position when scrolling. Maybe I want to go look at another part of the file and come back. How ca…

2) is generally accomplished with marks. Press m followed by a letter to set a mark where you are, go down to wherever you want, and then you can pop back by pressing ` (backtick) followed by the letter you set for the first mark.

If you want to go back and forth, you can set two marks.

Re: To Master Vim, Use It Like Language

#89

My issue with getting better at vim is that I've gotten to the point where I'm comfortable moving around text, copying/pasting, and everything I would normally do with a mouse. I know vim is so much more than that, but it's one of those things where "you don't know what you don't know" and because of that, I don't have the incentive to continue learning. Hopefully this post will inspire me to incrementally advance my…

advice: put just a bit more boring memorization type time into honing your discovery ability; ie hit the :h a bit, find some tutorials you like, pick up the "practical vim" book, print out a vim cheat sheet. not too much; just enough so you have somewhere to go when you have a question.

then, code in vim. at every pain point ask "is there some faster/easier way to do this?" sometimes you'll find something that seems great, then never use it again. other times, you'll relieve a recurring pain point and at the same time incorporate expanded facility with vim. after awhile, you'll pretty naturally start messing with vimscript as well.

in other words, i think videos and tutorials of "look at how powerful vim is in this situation!" can only go so far, at least until you've really expanded your horizons through practical use and need.

edit: the earlier advice in responses to you (some of which i basically just repeated) is good too. mine could be distilled into a sentence: "learn vim by coding in it, but allowing time for 'how could i do this better?'" on the one hand, just do your normal work. on the other hand, don't stay satisfied with being "good enough" at vim to do your normal work. that's where the learning curve is, and after you do that artificial thing (overdoing "can i make this easier?") it quickly becomes natural.

Re: To Master Vim, Use It Like Language

#90
From the article: "Arguably the most brilliant thing about vim is that as you use it you begin to think in it."

Bill Joy, regarding vi: "It's like one of those pinatas--things that have candy inside but has layer after layer of paper mache on top. It doesn't really have a unified concept. I think if I were going to go back--I wouldn't go back, but start over again."

Hunter S. Thompson, on an unrelated topic: "That was the fatal flaw [...] the desperate assumption that somebody--or at least some force--is tending the Light at the end of the tunnel."

I think vim is a useful tool. It's available on most systems and is powerful. But trying to grok it and appreciate its UI isn't really something I want to do.

Post reply on HN