3 ms·
This seems overdone to me. Vim out of the box is a perfectly adequate text editor, and all you need to know to use it is /?xiap ESC 99dd :wq! and the arrow key
by kragen 14y ago
This seems overdone to me. Vim out of the box is a perfectly adequate text editor, and all you need to know to use it is /?xiap ESC 99dd :wq! and the arrow keys. With gq (formerly Q, RIP) you can then edit text. hlJG<>wbvn.fF;#% help too, especially for code, and c is nice, especially ci, which is a Vim innovation. ^F and ^B move around. Then, if you're programming, you probably want to build a tags file and use ^] and ^T. Vim has g] and g^], which sound like they'd be nice for OO, but honestly I never use them, because at the point where I want an IDE instead of a text editor, I switch to Emacs. I use Vim every day for non-code things, though.
Learning the above is not going to take you two years or probably even two weeks.
This is my .vimrc:
set tabstop=4 shiftwidth=4 expandtab autoindent incsearch hlsearch
syntax enable
I've been using vi (and vim) since 1996, when I had vi installed locally on my workstation but had to load Emacs from NFS over a shared 10Mbps Ethernet. A few months later my roommate Payton Whitaker (RIP) made fun of me for using elvis, so I switched to vim, and I've been using it ever since, on probably half a dozen operating systems.
I've been using Emacs since 1993, but I used Epsilon for a few years before that. I've also used Eclipse, IDEA, Visual Studio, Squeak, and XCode, among other excellent development tools. I've also written a game in locally-hosted DHTML using TextEdit (from F-Droid) on Android, which was painful. The difference is just not that big.
An IDE is not going to turn you into a hacker. Just understand the system, look for limitations, and obliterate them.
That will make you a hacker.
- Mahn 14y agoVim out of the box is a perfectly adequate text editor, and all you need to know to use it is /?xiap ESC 99dd :wq! and the arrow keys. With gq (formerly Q, RIP) you can then edit text. hlJG<>wbvn.fF;#% help too, especially for code, and c is nice, especially ci, which is a Vim innovation. ^F and ^B move around. As somebody who never used Vim, I seriously can't tell if you are being sarcastic here.
- kragen 14y agoI was being serious, but I appreciate that my brief precis above is impenetrable to someone who hasn't used some flavor of vi. / search forward regexp ? search backward regexp x delete character i insert before the cursor a insert after the cursor (useful at end of line) p paste ("put") the last thing you deleted ESC stop inserting (exit insert mode, return to command mode) 99dd delete 99 lines :w RET save :q RET quit :w! RET save despite write-protection :q! RET quit discarding changes :wq save and, if successful, quit arrow keys move as usual. That much gets you an editor better than Notepad (because of instant search, with bonus regexps; multiple line ending support; and large file support), if somewhat more confusing, which you can use via ssh, and which won't lose your unsaved work if your machine crashes or runs out of battery. (Although you have to learn the :recover command to recover that unsaved work.) Occasionally you'll hit a wrong key and end up in some weird mode, which in Vim (unlike vi) displays at the bottom of the screen. Hit ESC to escape from the weird mode unless you feel like exploring it. If it split your screen and added another window (q: does this) then use :q to escape from it instead. One more thing I forgot at first, which is kind of essential: u undo ^R (control-R) redo For editing text, as opposed to code, you need to be able to refill (word-wrap) paragraphs so they aren't too ragged after you edit them. The command sequence {gq}, including the curly braces, will refill the paragraph your cursor is in. That's 22 commands to memorize, which you can do in less than a day. That much already gives you an editor dramatically better than Notepad, and probably better than Pico or Nano, too. You can now move around very rapidly, insert and delete, cut and paste, save or discard changes, and refill paragraphs. Unix was written with editors less powerful than this. For additional power, a second level of common commands, once you're comfortable with the 20 or so above: h move left (without having to take your hand off the home row) l move right G go to the end of the file 1G go to line 1 (the beginning of the file) w move right by a word b move left by a word n repeat the previous / or ? search fe find the next "e" on the line Fe find the previous "e" on the line ; repeat the last f or F command % jump to the matching parenthesis, bracket, or brace # (or shift-click) search for the last occurrence of the word you're on ^F forward a page ^B back a page Plus a few more editing commands: J join the next line onto this one > indent something (>> indent this line) < de-indent something (<< de-indent this line) c change something (cw change word) v highlight something with the cursor to delete, indent, change . repeat the last edit (insertion, deletion, or change) ci" change inside "" delimiters ci( change inside () delimiters (etc.) ^P, ^N in insert mode autocomplete the current word So that's another 25 or so commands, and now, after three days of vim, you can jump around in code like a madman (albeit in a single file); insert long method name identifiers with a few keystrokes; do interactive search and replace, using /, cw, n, and .; reindent blocks of code; and cut and paste in a more interactive way using v. At this point you probably want to set a few options, which you can enter using : or put in your .vimrc without :. :set incsearch makes / and ? search incrementally :set hlsearch highlights search hits :syntax enable enables syntax highlighting :set shiftwidth=4 makes < and > indent by four spaces :set autoindent begins each new line with an indent :set expandtab avoids putting TABs in the file (holywar) :set textwidth=72 auto-word-wrap at 72 columns Except for the last one, you probably don't need to learn these; just leave them turned on all the time. They're mostly turned off by default for backward-compatibility. There are some other commands I use on a regular basis (etyoIA*m',jkP|0^$^V^Z^GVC{}~:s) and others I use more rarely (Uq@, ZZ, :help, :set paste and :set nopaste, ^T and ^], ^W stuff, modelines, backreferences in regexp replacements) but I'm not confident that all of these are actually even valuable; I think knowing some of them just slows me down! And of course there's lots more of vim I don't know at all (the jump list, quickfix, grep, spell-checking, cindent, cscope, abbreviations, editing files inside archives, the file explorer, folding, Arabic, Farsi, Hebrew, multiple buffers, key mapping beyond :map, and everything to do with plugins, to name a few areas).