6 ms·
Why, oh WHY, do those #?@! nutheads use vi?
- brk 19y agoAwesome! I've been using vi for about 14 years now and am still learning new shortcuts and ways to harness the power of vi. I love vi for its combined power and simplicity. It is installed by default on almost every terminal I've ever walked up to, all flavors of nix, BSD, HP-UX, etc. seem to come happily installed with vi ready to go.
- chrisbroadfoot 19y agoMan, I agree with the notion of power, but I simply cannot see how anyone could call it simple. The array of keystrokes and their combined meanings is not anywhere near simple, in my opinion. That said, I would really like to sit down and learn vi sometime.
- tokipin 19y agoabout the longest 'combos' you make are action-move combos, which is 2 keys, and both the actions and move keys do things by themselves. 'w' for example moves to the beginning of the next word. it's a common travel key. 'dd' deletes the current line and is also commonly used. combine them into 'dw' and you delete everything up to the front of next word so you preface any motion command with an action and you get the intended effect. it's a lot more intuitive than it may look at first. a combo i use a lot is 'cw', which replaces the current word. but when programming this is equivalent to "replace variable." it's things like that (see the 'smart ranges' topic on that link) that make it feel like you're more directly connected with the code, rather than editing it through an interface
- chrisbroadfoot 19y agoAs I say, I do love the power of it and I'm sure I'd find it somewhat intuitive once I start using it, but it's just a steep learning curve when you can't fall back to input with a mouse. What I mean is: whenever I start learning a new program, I like to be able to use it like a n00b at first (i.e. click around, use native controls), and then learn the more powerful features. A good example of this way of learning is the way I use TextMate... every day I learn new controls, and get more proficient and more effective, but I'm not rendered useless (as one would be with vi) if I don't know each and every key combination. Granted, you can make do with just a few vi commands and be not effective at all, but it's not the same as using a GUI
- tokipin 19y agohttp://www.bemroses.net/images/curves.jpg http://www.bemroses.net/images/curves.jpg i've found the Cold Turkey method of learning very useful. there's a saying that goes something like, "the greatest catalyst for progress is necessity." when switching to dvorak i simply never touched quwerty again. likewise with Vim, i never used another editor. it's a bit odd at first, but if you keep yourself from using anything else, you will have to learn, or, as you say, you really will be useless. and due to that, you learn it faster than approaching it from a more reserved angle is it worth it? absolutely. editing code is a fundamental part of programming. it's something you're going to be doing a lot of. the investments you put into that aspect will pay off greatly the key to learning vi well is to be in command mode as much as possible
- brk 19y agoInteresting perspective, I'm wondering if you're a "Gen Y'er" (or whatever they're calling that newfangled generation these days ;) I ask because I started with PCs before the mouse was really commercialized. My first programs were on Commodore PETs and C64 and my PCjr. (Although I did later buy a mouse for the PCjr, I think it cost close to $200 at Babbages, had to save money for a while for that one...) My long-winded point being that I "grew up" with a CLI. We edited our text files with edlin (and we liked it, dammit!!). Maybe the folks who didn't get started viewing the mouse as a primary interaction device feel more comfortable with vi, and never really missed the mouse interface.
- LogicHoleFlaw 19y agoI'm wondering if you're a "Gen Y'er" (or whatever they're calling that newfangled generation these days ;) Apparently the defining starting birth year for that generation is 1982. I happen to have been born that year, and my preferred term for the generation is "Millennials". "Gen Y" over-emphasizes our interaction with the "slacker generation" which preceded us. Anyway, I don't think that there's much correlation between birth year and vi. With the rise to prominence of Linux and other Unix systems many many budding hackers are starting out with full-fledged command lines and honest-to-goodness Unix. And that's a beautiful thing.
- icky 19y ago> about the longest 'combos' you make are action-move combos, And then you use :wq as your finishing move!
- maximilian 19y ago:x is the same as :wq, so for those who don't like q's, you can save your pinky.
- icky 19y agoThat's only available on Super vim Fighter II Turbo Championship Edition.
- nostrademons 19y agoRegister-based yanks are longer, eg. to cut a block of code into the global clipboard so it can be pasted into another app, it's "+d}. I find myself using `cw`, `c%`, `ct,` (change everything up till the next comma), and `ct ` (change everything up till the next space) a whole lot too. The . command (mentioned in the article) is wonderful. Also, I love vim's macro support. For example, I usually define a macro that converts 'var' statements on separate lines into a single statement broken into multiple lines. (MTASC won't let you refer to previous vars defined in the same statement, so if I change the data dependencies, I usually have to change the formatting.) The entirety of the macro is `qa^dw>>[UP]$s,[ESC][DOWN][DOWN]q`. That's `qa` to start recording a macro into register `a`, ^ to move to the first non-blank character, dw to delete a word ('var ', in this case), >> to shift the line left by 4 spaces, UP moves up a line, $ goes to end of line, `s,` substitutes a , for the ; at the end of line, ESC gets back into command mode, the two DOWNs put me on the line below where I started, and q stops recording. Then if I want to replace 5 lines of variable declarations, I can do 5@a (invoke macro a 5 times), and since each macro ends exactly one line lower than it started, it'll do the whole block for me at once.
- antiismist 19y agoMy longest day-to-day combo is "vabx" or "vaby". Basically, for lisp code, it selects the entire s-expression including the parens, and either removes it or deletes it.
- rumblerob 19y agoSomeone should tell them that their "VI Gang Sign" is a pretty close analogue of the Shocker. (Not that that couldn't be a convincing argument to learn vi...)
- derefr 19y agoThey already know (search for "the Shocker"): http://blog.ngedit.com/2007/11/19/the-vi-gang-sign/ http://blog.ngedit.com/2007/11/19/the-vi-gang-sign/
- wfarr 19y agoBeing a dedicated emacs user, I could only shake my head and sigh as I read this.
- SwellJoe 19y agoThe first step is admitting you have a problem. You're on the right track.
- hooande 19y agoI would love to get into a lengthy discussion about why the One True Editor is superior to vi, but I have a feeling that it would just degenerate into a flame war. vi does have an advantage in that it comes standard on most unix servers, while emacs requires a long (but relatively painless) install. Let's just say that in terms of power the two are about equal. I think emacs has an edge in the macros/functions department but vi isn't far behind. It's probably also fair to say that either one of them are probably better than a Windows based IDE if you're working with open source software (ruby, php, perl etc).
- SwellJoe 19y agoI'm sorry, I can't hear you over the sound of how awesome my text editor is.
- wfarr 19y agoI left vi(m) behind over a year ago, so I'm not sure what you're getting at here. ;)
- Hexstream 19y agohjkl motion is retarded on anything but a qwerty layout :/
- tokipin 19y agoi use vi with Dvorak without any key remappings. it did take some getting used to at first when switching, but probably less getting used to than it took when i was first learning it on qwerty also, hjkl aren't used often. you don't usually have to alter just one character in a word for example. the movement commands i use the most are (by far) 'w' and 'b' (next/previous word)
- demallien 19y agoworks just fine on my azerty keyboard....
- Hexstream 19y agoI know, I consider that's in the qwerty group, mind you. Especially since the hjkl keys are at the same place than on qwerty, so your "clever" remark is irrelevant.
- sabat 19y agoConfession: I use vi because when I was learning how to be a sysadmin (was already a coder) it was recommended -- back then (the '90s) you never knew if emacs was going to be on a system, but vi was practically guaranteed. I still barely know how to use it, though: my own fault. Laziness prevails. Some of the commands I use because I discovered them by accident (shift-C erases the rest of the line and puts you into edit mode -- I figured that one out because of a typo).
- kmt 19y agoDoes this mean that nowadays you can expect emacs to be installed on every system? From what I've seen, still no. So basic vi skills are still needed. But nowadays, there are many ways to avoid having to edit files with vi. If a system has sftp access you can mount it's file system via sshfs and edit files from your main machine in emacs. This way you could even have the files version controlled on your main machine. There's also tramp mode of course, but sshfs works better.
- LogicHoleFlaw 19y agoWhen you really need vi, you really need it. I'm talking about connecting to servers halfway around the world with the only access being via a serial connection. Straight-up serial console, none of this fancy newfangled terminal emulator nonsense. No amount of emacs and sshfs will help you then.
- brentr 19y agoMy experience with vim started when I got OS X. I had always wanted to learn how to use the terminal on a UNIX machine, and as an extension of that want, I learned to use vim as it was very easy to jump right into it from the terminal. If there was one word that I could use to describe vim, I would have to say: beautiful.
- mechanical_fish 19y agoThis article is excellent. I'm an emacs user, and I know of several articles and books that introduce emacs, but this is the first time that I've ever actually understood how a vi master thinks.
- whacked_new 19y agoWow, the '.' is certainly an enviable feature. http://meghnad.iucaa.ernet.in/intranet/sysadm/help_desk/emacs/49.html http://meghnad.iucaa.ernet.in/intranet/sysadm/help_desk/emac... isn't reassuring either. How does C-x (, C-x ), and C-x e compare? http://linuxgazette.net/issue47/pedersen.html http://linuxgazette.net/issue47/pedersen.html
- apathy 19y agoEsc-Meta-Alt-Ctrl-Shift ;-) I started out in Emacs, made the leap to XEmacs, learned to write elisp, then one day I discovered that Vim syntax highlighting was pretty damn good too... it was all over. Vim + Screen == Real Ultimate Power
- mechanical_fish 19y agoThe emacs macro features compare pretty well. They're a killer feature of emacs. The editor is named after macros, after all. You can probably accomplish much of what vi's "." does using emacs macros. The trick is that in emacs you have to notice the opportunity slightly in advance, so that you can hit 'C-x (' and then plan out your macro so that it plays back well on subsequent invocations. You could probably train yourself to think of that more often, after which your emacs experience might be roughly similar to that of the vi user. But I suspect that vi is better designed for such a macro-intensive style of editing. The beauty of "." appears to be that vi workflow naturally divides into little chunks of action, each of which can then be treated post facto as a macro. This explains my #1 pet peeve as a completely ignorant vi user -- that vi is so damned choppy, always switching in and out of insert mode. That's not a bug, it's a feature! Those little transitions are the waypoints that will later be used to break your workstream into repeatable chunks.
- apathy 19y ago
- noonespecial 19y agoWhy I like vi/vim. Its always there. Even on tiny linux distros. It allows me to operate just as fast on extremely high latency connections. It was the only usable editor when I was stuck with 650ms+ latencies on VSAT.
- hernan7 19y agoAn oldie but a goodie. Back when I started working on Unix (early 90s), the only editor on the lab machines vi. The learning curve was horrible, but after that I never was able to use an editor for human beings again. Nowadays, when I'm trapped in a Notepad derivative, it's all jjjjjjkkkkkkwwwww for the love of God Montesor, give me back my dot!!!
- NonEUCitizen 19y agore: newbies, must be gmail's fault for adopting vi keybindings. e.g. j to navigate down and k to navigate up (in "list view").
- graywh 19y agoGoogle Reader, too.
- god 19y agoThe only problem I see with vim is that today I write everything online. In textboxes like the one I use right now to type this text. Maybe we need a firefox extension, that blows up a textarea fullscreen and edits it with vim?
- jlg 19y agoTry Mozex.
- bootload 19y ago"... Try Mozex ..." Wow I'm editing with it now & it works well. Some observations: - It would be nice if it was just concentrated on editing. - Certainly a much nicer alternative than the textbox - miss the spelling syntax highlighting - It doesn't appear to allow you to edit in the textbox after editing :( - you need to :wq! & hit enter to save Can be found at http://mozex.mozdev.org/development.html http://mozex.mozdev.org/development.html
- graywh 19y agoTry ViewSourceWith. https://addons.mozilla.org/en-US/firefox/addon/394 https://addons.mozilla.org/en-US/firefox/addon/394 You can set Vi/Vim as the default editor and use it to edit text boxes and view the page source. You can also set up other editors (e.g. Gimp for images).
- apu 19y agoI've always used (and loved) It's All Text: https://addons.mozilla.org/en-US/firefox/addon/4125 https://addons.mozilla.org/en-US/firefox/addon/4125 It adds a small "edit" button at the bottom right of any textbox, which will then let you edit the contents of that box in your favorite text-editor. Works fine in news.yc, gmail, wordpress, etc. Incidentally, a similarish extension for thunderbird is called "External Editor": http://www.kickflop.net/blog/2005/12/22/using-an-external-editor-with-thunderbird/ http://www.kickflop.net/blog/2005/12/22/using-an-external-ed... (It's a little annoying to find, download, and install, but it works fine once you do.) It also works great with vim syntax highlighting for emails, with headers and quoted previous emails appropriately colored.
- marrone 19y agoI switched to vim for a few reasons: - I didn't want to get trapped into being comfortable with some editor that I would later not have access to. vim will always be there on any unix box - there are no showstoppers for vim. Every other editor is great because it has x and y, but the lack of z is annoying. with vim, you can configure it to do almost anything with macros in your .vimrc - it was slow to get going at first, but now I find using vim you can edit files much faster than using the mouse.
- chrisc 19y agovim7 especially is great with the new tab features and omni-complete
- davidw 19y agovi might be on any unix box, but not vim.
- SwellJoe 19y agoThat's true. I'm working on FreeBSD support in our products right now, and every time I type "vi filename", I either get frustrated as hell for the few bits of typing I have to do, or I notice immediately and :q and "vim filename" to get the right thing. Since I'm spawning new instances for each testing cycle (I'm building a product installer) it's a bit of a nuisance to make an alias each time. The default csh shell also pisses me off.
- ten-seven 19y agoBack when I was coding a lot, there were two editors, vi and one other that came with the Unix variant we had. The other "visual" editor had an annoying tendency to convert multiple spaces to tabs if it was able to. This broke formatting and messed up make files. It sparked a holy war against those who "maintained" code with that editor, calling for those people to use vi and stop breaking things.
- jng 19y agoI'm the author of the linked article (and of the ViEmu products). Thank you guys for taking some time to read it. The funny thing is that having vi/vim editing inside Visual Studio is bringing in new converts: http://www.jpboodhoo.com/blog/GettinJiggyWithVIM.aspx http://www.jpboodhoo.com/blog/GettinJiggyWithVIM.aspx http://www.jpboodhoo.com/blog/HookedOnVIM.aspx http://www.jpboodhoo.com/blog/HookedOnVIM.aspx Of course I'm not impartial, but I would recommend you consider giving it a try if you have access to vi, vim, or emulation for them in your IDE (and some time). I miss having it in Firefox textareas (such as when typing this comment). I don't like using an external text editor for this - integration is everything to me. I'd happily pay for it, and I'm sure others would, too, although of course it's not a big market. Anyone up to the task?
- LogicHoleFlaw 19y agoFirst, thank you for writing this article. It's the best explanation I've seen of what vi is all about. I'm pointing several friends at it today to help explain my vim addiction. Your graphical cheat-sheet is also excellent. (http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial... for those following along) When I started learning vim I printed it out and it's still hanging on my cube wall. It really captures a lot of the mnemonics and helped me get up to speed quickly. I was forcibly introduced to vi when I was doing some system administration on some AIX machines. Emacs was not available and I'm not even sure if something as simple as pico was. Since I was going to be doing a lot of work on these boxes I decided to learn vi. It was one of the best computing decisions I've ever made. I've been using vim for about two years now and everything has just become instinctive. When I'm using another editor I just feel crippled. I still feel like there's a lot I can still learn - I try to pick up a new trick at least once a week. Here's my current list of tricks from my .vimrc file. I still tweak it but it's pretty stable these days. " enable vim goodies set nocompatible " tab policy: spaces only, 4 per indentation level " (company policy, don't flame me) " use language-sensitive indentation where available " use :retab to fix nonconforming files set tabstop=4 set shiftwidth=4 set shiftround set expandtab set smarttab " use syntax highlighting filetype on syntax enable " use auto-indentation set cindent set ai set number " misc options set matchpairs+=<:> " bounce matching angle brackets on % set hidden " don't kill buffers, just hide them set incsearch " incrementally search (firefox does this too) set ignorecase " ignore capitalization when searching set scrolloff=5 " scroll the screen to keep the cursor more than 5 lines in set showbreak=\ " display wrapped lines with a leading '\' set breakat-=- " allow wrapping words at '-' set linebreak " allow word wrapping " colorscheme desert " previous favorite colorscheme colorscheme vibrantink " current colorscheme borrowed from textmate " include arc support (via plugin from the anarki) au bufnewfile,bufread *.arc set ft=arc " show all matching files when expanding wildcards set wildmode=longest,list " don't display the graphical toolbar (it annoys me) set guioptions-=T " ********** Custom Keybindings ******************** " CTRL-k and CTRL-k move the current line up or down nmap <silent> <C-j> :m+<CR> nmap <silent> <C-k> :m-2<CR> imap <silent> <C-j> <C-O>:m+<CR><C-O> imap <silent> <C-k> <C-O>:m-2<CR><C-O> " backwards-kill-word idea cribbed from Steve Yegge " hit CTRL-h (insert and normal mode) to delete the word " you are currently typing. It's faster than backspacing. nmap <silent> <C-h> ciw map! <silent> <C-h> <Esc>ciw " hit F1 to toggle match highlighting map <F1> :set invhlsearch<CR> " linux friendly: paste the current X selection on middle mouse button map <S-Insert> <MiddleMouse> map! <S-Insert> <MiddleMouse> " ************* Load Plugins ***************** " start matchit source $VIMRUNTIME/macros/matchit.vim " Toggle the TagList nnoremap <silent> <F8> :TlistToggle<CR> let Tlist_GainFocus_On_ToggleOpen = 1 let Tlist_Exit_OnlyWindow = 1 let Tlist_Use_SingleClick = 1 let Tlist_Process_File_Always = 1 " Toggle BufExplorer map <F9> \bs let g:bufExplorerShowDirectories=0 " Don't show directories. let g:bufExplorerSplitBelow=1 " Split new window below current let g:bufExplorerSplitHorzSize=0 " Use this many lines for the window let g:bufExplorerUseCurrentWindow=1 " Open using current window
- acrylicist 19y agoDoes anyone else resort to writing vi commands down on paper when they are writing in pen or have no eraser for corrections?
- tel 19y agoIs there any article like this specific to lisp? What really turned me on to Emacs was learning about Slime, largely through Marco Baringer's videos (they're linked from this post: http://bc.tech.coop/blog/050728.html http://bc.tech.coop/blog/050728.html)
- meat-eater 19y agoI work equally well in vi and emacs. Now I've switched from emacs to textmate, but still use vi for editing config files. It's just how I work, vi for config files, another editor for code. Of course, I also use vi to write short scripts on the server. I've been using vi for over 10 years, but this article showed me why it might be a good idea to edit code with it.