Live data from Hacker News

To Master Vim, Use It Like Language

danielmiessler.com

61–70 of 124 posts

Re: To Master Vim, Use It Like Language

#61

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…

Being able to move about is the first step. The second is to see that you can combine actions with motions. There are many more, of course - but IMHO, crossing these two steps takes you past the tipping point.

For example - '%' matches parentheses and braces. So if you want to delete a block of code, you could go to the opening (or closing) brace, and do "d%". If you wanted to indent only that block of code, you'd do "=%". In this context, ":help motion.txt" makes for a good read.

Apart from this, I'd also recommend listing down things about your current workflow that you find irritating, and trying to find solutions for them in vim.

For instance - I wanted to be able to browse through cscope matches in a regular vim buffer than the ridiculous less-like interface that's the default. I found quickfix, which solved my problem neatly. I then wanted to open each match in a vertical split, rather than in the same window - I ended up writing a little bit of vimscript and a keybinding for this.

Sometimes, when going through a gazillion cscope matches, I find it convenient to hide stuff that isn't relevant - I use (manual) folds for this purpose.

Re: To Master Vim, Use It Like Language

#62

Earlier quoted context omitted.

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.

He does have a point. Using vi derivatives does seem a tad spartan today, and I've personally never been a fan of vi, nor of emacs, but much of the community has this pseudo-elitist dichotomy set up around those two editor families. I'm not really a fan of what passes as IDEs, either, but I generally am not attached to any particular editor and hop around them. (The right answer to vi vs. emacs is, of course, Acme.)

I actually began using Acme a couple of months ago: it's kind of interesting how much I have accustomed to mouse-driven interaction and lack of syntax highlighting. Humans indeed are creatures of habit.

Re: To Master Vim, Use It Like Language

#63

Earlier quoted context omitted.

Aiming to combat "you don't know what you don't know", here's a list of things to consider. How comfortable are you with: * find/replace/regexes * registers and macros * vim settings (spell, list, highlight, number, wrap) * the plugin ecosystem * editing multiple files simultaneously (splits, buffers, moving between them) * folds Anyone else want to chime in with stuff I've either forgotten or don't know I don't know…

Opening a new buffer. Figured I'd try :new, and wound up getting good at splits. Still don't know how to just open up a new, blank buffer in the window I'm in without specifying a filename to :e.

If you don't mind getting your hands dirty with a little vimscript, you can set the buftype to nofile, and open a "scratch buffer" of sorts.

Re: To Master Vim, Use It Like Language

#64

Earlier quoted context omitted.

Aiming to combat "you don't know what you don't know", here's a list of things to consider. How comfortable are you with: * find/replace/regexes * registers and macros * vim settings (spell, list, highlight, number, wrap) * the plugin ecosystem * editing multiple files simultaneously (splits, buffers, moving between them) * folds Anyone else want to chime in with stuff I've either forgotten or don't know I don't know…

Opening a new buffer. Figured I'd try :new, and wound up getting good at splits. Still don't know how to just open up a new, blank buffer in the window I'm in without specifying a filename to :e.

:enew

Re: To Master Vim, Use It Like Language

#65
post #29
post #5

Earlier quoted context omitted.

Haven't used ESC since finding out Ctrl-C.

bonus is that Ctrl-C gets you out of pretty much any mode. Also, while in insert mode, using ctrl-h for backspace and ctrl-w for delete word are really nice.

Better yet, ^[ is actually ESC in vi/vim, and works without a config change. I started using this last year and haven't looked back. ^C works well, but I recall it having some limitations in certain environments (though for the life of me I can't recall what they were).

In any case, I prefer ^[ to ^C, and hopefully you will too!

Re: To Master Vim, Use It Like Language

#66
post #48

Earlier quoted context omitted.

Marks (non-global, global), the quickfix list, tabs, vimscript, python bindings, there's a lot. Vimcasts ( http://vimcasts.org/ ) has some good tutorials. Vimgolf ( http://vimgolf.com/ ) also has some good exercises.

Oh neat! I didn't know about global marks before.

Capital letters and numbers are global, lowercase is buffer local. There are also dynamic marks that vim sets which you can use instead of manually navigating or setting marks. For example, g'. will go to the position of the last change. You can use :help marks to get a lot more info.

Re: To Master Vim, Use It Like Language

#67

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…

Aiming to combat "you don't know what you don't know", here's a list of things to consider. How comfortable are you with: * find/replace/regexes * registers and macros * vim settings (spell, list, highlight, number, wrap) * the plugin ecosystem * editing multiple files simultaneously (splits, buffers, moving between them) * folds Anyone else want to chime in with stuff I've either forgotten or don't know I don't know…

Ag support and ctrl-p

https://github.com/rking/ag.vim https://github.com/kien/ctrlp.vim

Save me so much time opening files and finding matches+open-at-match

Re: To Master Vim, Use It Like Language

#68
post #64

Earlier quoted context omitted.

Opening a new buffer. Figured I'd try :new, and wound up getting good at splits. Still don't know how to just open up a new, blank buffer in the window I'm in without specifying a filename to :e.

:enew

Thanks :) I'd completely forgotten about enew.

Re: To Master Vim, Use It Like Language

#70
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.

Same here. I did both jk and kj. When I want to leave insert mode, I just mash those keys.
Post reply on HN