Live data from Hacker News

Why, oh WHY, do those #?@! nutheads use vi?

viemu.com

31–40 of 53 posts

Re: Why, oh WHY, do those #?@! nutheads use vi?

#31
post #20

The 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?

Try ViewSourceWith.

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).

Re: Why, oh WHY, do those #?@! nutheads use vi?

#32
post #7

Earlier quoted context omitted.

Man, 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.

about 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…

Register-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.

Re: Why, oh WHY, do those #?@! nutheads use vi?

#35
post #21

I 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 fi…

vi might be on any unix box, but not vim.

Re: Why, oh WHY, do those #?@! nutheads use vi?

#36
post #28

I'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/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…

First, 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... 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   :m+
  nmap   :m-2
  imap   :m+
  imap   :m-2

  " 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   ciw
  map!   ciw

  " hit F1 to toggle match highlighting
  map  :set invhlsearch

  " linux friendly: paste the current X selection on middle mouse button
  map  
  map!  

  " ************* Load Plugins *****************
  " start matchit
  source $VIMRUNTIME/macros/matchit.vim

  " Toggle the TagList
  nnoremap   :TlistToggle
  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  \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

Re: Why, oh WHY, do those #?@! nutheads use vi?

#37
post #20

The 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?

I've always used (and loved) It's All Text:

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

Re: Why, oh WHY, do those #?@! nutheads use vi?

#38
post #28

I'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/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…

First, 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... for those following along) When I started learning vim I printed it out and it's still hanging on my cube wall. It really capture…

Thanks for your kind comment! I'm glad the article and cheat sheet are useful and appreciated.

I got started with vi(m) about 3 years ago. I did actually do some development on AIX over 10 years ago (that system looked like a washing machine!), but I didn't get hooked with vi(m) until I really did a lot of development on a laptop with horrible keys:

http://blog.ngedit.com/2005/06/03/the-vi-input-model/

Your .vimrc is much more complex than mine! But very nice in any case, I should steal a trick or two from there.

A detail I remember about the AIX system headers: their math.h defined a function called 'class'. I had to do some #defining around that to get them to work with the C++ compiler! It was '96 or so, so they should have taken C++ into account already. Duh. At least it wasn't as horrible as windows.h and its accomplices.

Re: Why, oh WHY, do those #?@! nutheads use vi?

#39
I 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.

Re: Why, oh WHY, do those #?@! nutheads use vi?

#40

This 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.

Plus it's a brilliant ad for his product. Basically, "here's why I wrote this product, once you get hooked on Vim, come back and I'll sell it to you for your day-to-day work."

Genius! This is what Hacker News is all about, conversion rate :-)

Post reply on HN