Live data from Hacker News

Vim Cheat Sheet - For Programmers By Programmers

michael.peopleofhonoronly.com

51–60 of 64 posts

Re: Vim Cheat Sheet - For Programmers By Programmers

#51
post #41
post #22

This is why I only use the most basic features of vim. There are simply too many commands to learn and many of these tutorial and cheatsheets present you with too much information. I don't think the time investment makes sense, and I don't understand why there has to be so much noise: how many of those commands save a significant amount of time; how often are they used? The questions I would like to ask advanced vim…

The thing is.. there's a really step learning curve in learning the fundamentals of vim, but once you know them, it takes a second to learn a new command. For instance, dt' will delete characters until it matches a' . But also, dtf' will delete characters until it matches a' but also delete that ' . T and F goes backward.. you can put a number in front of the command to delete until it matches the nth ' , etc. It loo…

Worth noting: cib == ci), and ciB == ci}.

Also, "a" instead of "i" includes the enclosing markers. Not really that useful for braces and parens, but for strings da" is great. da[ is pretty great for Obj-C, too.

Re: Vim Cheat Sheet - For Programmers By Programmers

#52

Earlier quoted context omitted.

Pressing Tab completes commands in command-line mode, and its very smart. (Be sure to :set wildmenu to see a list of all matching commands as well.)

Even without wildmenu option, repeatedly pressing TAB key will cycle through the list of matches.

What's more, you can press to view the whole list of possible completions at one time. For example, enter ':colo ' then press and you'll see a list of all the colorscheme names. (The space in ':colo ' is important, since if you press ctl-D with just ':colo' Vim will just show you the 'colorscheme' completion. . . )

Re: Vim Cheat Sheet - For Programmers By Programmers

#53
post #12
post #7

I started out vim, with bare minimum commands but later on went to emacs. With emacs I have an option M-x tab auto complete In case I don't get to remember something. I would like to know what are vim equivalents of this? Some how I feel deep down inside that vim was not designed bottom for this kind of complexity. I mean to say when you want to design something to scale you have to clearly decide what goes into the…

vim will auto complete words if you press control-p while in insert mode. http://i.imgur.com/tdcEc.png For what it's worth I feel how you feel about vim, about emacs. I suspect it's just a matter of familiarity. edit: As DrJ points out, control-n works too. Seems the 'p' is for previous keyword and the 'n' for next keyword.

The "M-x " that kamaal is talking about is for editor commands. Similar to ": " in Vim. The difference being that all of Emacs' editor commands (even "move one char to the left") are elisp functions that are available from the M-x prompt.

Re: Vim Cheat Sheet - For Programmers By Programmers

#54
post #36

One useful command that was missed: C-^ (aka Ctrl-6) switches back to the most recently used buffer. That is, if you are using two buffers, you can just flip back and forth with C-^

Of note:

1) OSX will not send any sequence when you press C-6 in Terminal.app. You have to press C-S-6 or C-^. I've never had this issue on Linux. Either C-6 or C-^ will work.

2) If you launch Vim with "vim file1 file2", the Ctrl-6 buffer switching will not switch you between file1 and file2 until you manually do it for the first time in that Vim session.

3) The Ctrl-6 switching is frame-dependent. The "previous buffer" is maintained locally between window splits or tabs in Vim, so you could have a vertical split that allowed you to easily swap between 4 separate files (i.e. 2 per side).

Re: Vim Cheat Sheet - For Programmers By Programmers

#55
post #36

One useful command that was missed: C-^ (aka Ctrl-6) switches back to the most recently used buffer. That is, if you are using two buffers, you can just flip back and forth with C-^

This is awesome, thanks. Every day is a day to learn new stuff in vim. :)

Re: Vim Cheat Sheet - For Programmers By Programmers

#56
post #7

I started out vim, with bare minimum commands but later on went to emacs. With emacs I have an option M-x tab auto complete In case I don't get to remember something. I would like to know what are vim equivalents of this? Some how I feel deep down inside that vim was not designed bottom for this kind of complexity. I mean to say when you want to design something to scale you have to clearly decide what goes into the…

I agree that this is way too much information to be useful. I like focused cheatsheets that help you on a particular aspect that you're trying to improve. I created a cheatsheet for the most important vim movement commands that helped me focus to memorize all of them rather than get overwhelmed (http://naleid.com/blog/2010/10/04/vim-movement-shortcuts-wal...).

Re: Vim Cheat Sheet - For Programmers By Programmers

#57
post #7

I started out vim, with bare minimum commands but later on went to emacs. With emacs I have an option M-x tab auto complete In case I don't get to remember something. I would like to know what are vim equivalents of this? Some how I feel deep down inside that vim was not designed bottom for this kind of complexity. I mean to say when you want to design something to scale you have to clearly decide what goes into the…

I recently written this introduction:

http://goo.gl/oRn1K

It received quite a lot of positive returns.

But the idea behind vim is you don't learn vim like you learn a lesson. You learn vim like you learn piano. You have to use it against your intuition for some days until you're accustomed to it. Once done, you'll start to progress by adding a new habit regularly.

The most difficult part is to start and continue until you reach a standard usability zone. After each new trick will make you better, stronger, faster.

Re: Vim Cheat Sheet - For Programmers By Programmers

#58
post #49
post #22

This is why I only use the most basic features of vim. There are simply too many commands to learn and many of these tutorial and cheatsheets present you with too much information. I don't think the time investment makes sense, and I don't understand why there has to be so much noise: how many of those commands save a significant amount of time; how often are they used? The questions I would like to ask advanced vim…

The first Vim commands people learn generally fall into this set: i, i_ , gg, h, j, k, l, yy, dd, p, :w, :q. But any computer literate person should be able to operate on this level in a basic "Notepad" application. The be highly productive in Vim, I think you'll need to learn closer to 50 commands. Now, if you think learning 50 commands is hard, think about your ability to touch type: that's at least 50 keys. Think…

> any computer literate person should be able to operate on this level in a basic "Notepad" application

Yes, although I will say that dd, p and P when properly wielded are a nice boost in power over optimal Notepad editing, even with mastery of the system-specific modifier key selection techniques.

Re: Vim Cheat Sheet - For Programmers By Programmers

#59
post #7

I started out vim, with bare minimum commands but later on went to emacs. With emacs I have an option M-x tab auto complete In case I don't get to remember something. I would like to know what are vim equivalents of this? Some how I feel deep down inside that vim was not designed bottom for this kind of complexity. I mean to say when you want to design something to scale you have to clearly decide what goes into the…

Personally I found vim easier to memorize than emacs commands and that's one of the reasons I went with it. If you work in vim day in and day out for a year (with a little curiosity and exploration) you should have most of this cheat sheet committed to muscle memory and move on to formulating more complex macros and using more advanced vim plugins to their potential.

I agree that emacs is more elegant in its implementation, but then again I think the very foundation of building an editor in lisp creates a level of elegance that is almost impossible to reach by any other path. In other words, vim is less elegant, but I don't think it's bad.

Fundamentally I see vim/emacs as unequaled peers. Vim is optimized for raw text editing potential, and emacs is optimized for customizability. Vim is still richly extensible, and emacs is still powerful for raw editing out of the box, but they lose out to each other on their respective strengths. I think the vim expert will be more effective editing disparate files on vanilla systems, and the emacs user will be more effective customizing his environment for his particular workflows.

Re: Vim Cheat Sheet - For Programmers By Programmers

#60
post #27
post #22

This is why I only use the most basic features of vim. There are simply too many commands to learn and many of these tutorial and cheatsheets present you with too much information. I don't think the time investment makes sense, and I don't understand why there has to be so much noise: how many of those commands save a significant amount of time; how often are they used? The questions I would like to ask advanced vim…

I prefer to think of the commands being organized conceptually, not by location. Something like this: http://fprintf.net/vimCheatSheet.html So, if you are just starting out, learn the basic command(s) for doing each thing. Then, as you do it over and over, you'll begin to wonder how to do it easier. That's where the more advanced commands come in. I do have printed cheat sheets that I occasionally will look at and sa…

Also recommended: Mug of Vi (http://nostarch.com/mug.htm)

:)

Post reply on HN