Live data from Hacker News

Coming Home to Vim

stevelosh.com

51–60 of 125 posts

Re: Coming Home to Vim

#51

Earlier quoted context omitted.

If you say why Gedit was faster perhaps us vim fanatics can help you understand us.

Let's say I need to change a word. With Gedit, I double-click the word and retype it the right way. With Vim, I press j until I'm on the line where the word is, then I press w until I'm at the beginning of the word, then I press cw to change the word, retype it the right way, and press escape to go back to command mode. Triple-clicking in Gedit highlights a line. Triple-clicking and dragging highlights a contiguous g…

"With Vim, I press j until I'm on the line where the word is, then I press w until I'm at the beginning of the word, then I press cw to change the word, retype it the right way, and press escape to go back to command mode."

OK, this is something Vim people need to work on. Using j/k to move more than one or two lines is the wrong way to do things.

I know, I know, we extoll the virtues of hjkl constantly, but really they're barely more effective than the arrow keys.

There are better ways to move around in Vim, such as [f]orward, '[t]il and searching. In your case (changing word XYZ to something else) I would search for the word with /XY… and press return to get there, then edit as you described.

"Triple-clicking in Gedit highlights a line. Triple-clicking and dragging highlights a contiguous group of lines. In Vim, I'd need to move to the line I want to begin my selection on ([number]G or jjj), then press V, then press jjj until everything is selected."

See my previous comment about movement. You'd move to the line you want by using a search (or '{', which moves to empty lines), start your selection with V, and move to the end with another search (or some kind of movement command that gets you where you want to go quickly).

We Vim users need to stop touting our Nethack-honed hjkl skills and start talking about Vim's better movement commands.

"And I don't have to deal with the fact that the default way of deleting things overwrites the default clipboard either."

Yeah, this is dumb. YankRing helps a lot by letting you 'Ctrl+P' to the right text, but I really think Vim should have a "clipboard register" that only gets overwritten when you mean it (and have other registers for the last yanked elements).

"when I paste code in to a Vim document, the indentation gets all screwed up."

If you're using a graphical Vim like gvim or MacVim this simply shouldn't happen. It's a bug and you could report it.

If you're using the command line Vim you might need to do a bit more work to launch Vim and tell it to talk to X. It's a few extra minutes up front, but such is the price of using a terminal-based editor in a graphical environment.

Re: Coming Home to Vim

#52

TextMate doesn't have split windows?!

Nope. It's one of the biggest complaints about Textmate, and one of the things that led me to (mostly) switch to vim.

A lot of people are pretty upset with the author because rather than choosing to release an incremental update that adds smaller features like this, he decided on a total rewrite and got bogged down with no release in sight.

That said, Textmate still feels remarkably current despite the fact that its last major update was more than 4 years ago.

Re: Coming Home to Vim

#53
>Some people use a mapping that turns search highlighting off and on, but I don’t like that solution. It means I have to remember to turn it back on later once I’ve probably already forgotten about the original search.

:nohlsearch removes highlighting, doesn't modify search history, and also doesn't disable highlighted search. It will still highlight matches for the next search.

  > nnoremap S ?{jV/^\s*\}?$k:sort:let @/='' 
I'm curious why not just use `ViB:sort`?

> When I press return, create a new line at the same indentation level as the current one. Don’t try to be clever and adjust the indent of new line in any fashion.

  set autoindent nosmartindent nocindent
Wrap it in a filetype line if you like.

Re: Coming Home to Vim

#54
A litte off topic. Much that I like vim I haven't found any plugin than can indent Javascript properly. To be honest whenever I write Javascript I just open up emacs. Is there something close to js-mode in vim?

Re: Coming Home to Vim

#55
post #2

One of the things I love about Vim is that every time I read though a post like this or look at someone's .vimrc I learn something new about what it can do or get another insight about how its features can make my life easier. My (semi-commented) .vimrc is on GitHub if anyone wants another example: http://github.com/samdk/vimconf/blob/master/dotvimrc I've also found StackOverflow's list of most-voted questions tagged…

Another good vimrc is the vimrc from grml http://git.grml.org/?p=grml-etc-core.git;a=blob_plain;f=etc/...

It is a good start to a simple but yet powerful vim configuration, especially integration with screen, pastetoggle, etc.

Re: Coming Home to Vim

#56

Earlier quoted context omitted.

If you say why Gedit was faster perhaps us vim fanatics can help you understand us.

Let's say I need to change a word. With Gedit, I double-click the word and retype it the right way. With Vim, I press j until I'm on the line where the word is, then I press w until I'm at the beginning of the word, then I press cw to change the word, retype it the right way, and press escape to go back to command mode. Triple-clicking in Gedit highlights a line. Triple-clicking and dragging highlights a contiguous g…

To add to what Steve said, I would say: don't be afraid to use the mouse if you're in a graphical Vim. In MacVim, if I want to change a word, I'll double-click it, hit c and type whatever I want.

You might say, "But you had to hit 'c' instead of just typing!"

Maybe, but I could run any number of commands over that word instead of just changing it. Also, if I were in insert mode, double-clicking and typing would overwrite the word as if I were in a normal editor.

Re: Coming Home to Vim

#57

Earlier quoted context omitted.

If you say why Gedit was faster perhaps us vim fanatics can help you understand us.

Let's say I need to change a word. With Gedit, I double-click the word and retype it the right way. With Vim, I press j until I'm on the line where the word is, then I press w until I'm at the beginning of the word, then I press cw to change the word, retype it the right way, and press escape to go back to command mode. Triple-clicking in Gedit highlights a line. Triple-clicking and dragging highlights a contiguous g…

Since you seem to compare terminal vim vs gedit: How do you run gedit in a terminal?

I gvim you could have used the mouse too.

Re: Coming Home to Vim

#58

Earlier quoted context omitted.

If you say why Gedit was faster perhaps us vim fanatics can help you understand us.

Let's say I need to change a word. With Gedit, I double-click the word and retype it the right way. With Vim, I press j until I'm on the line where the word is, then I press w until I'm at the beginning of the word, then I press cw to change the word, retype it the right way, and press escape to go back to command mode. Triple-clicking in Gedit highlights a line. Triple-clicking and dragging highlights a contiguous g…

You can also use the mouse with vim.

set mouse=a and the behaviour is the same, tripple click hilights a line and you can drag your mouse around to highlight a contiguous group of lines.

regarding the system clipboard, yeah thats messy, but you can easily map a key to toggle the paste mode (set pastetoggle=) or get the content from the the clipboard via some keybinding (shift-F7) map :r!xclip -o

Re: Coming Home to Vim

#59

Earlier quoted context omitted.

If you say why Gedit was faster perhaps us vim fanatics can help you understand us.

Let's say I need to change a word. With Gedit, I double-click the word and retype it the right way. With Vim, I press j until I'm on the line where the word is, then I press w until I'm at the beginning of the word, then I press cw to change the word, retype it the right way, and press escape to go back to command mode. Triple-clicking in Gedit highlights a line. Triple-clicking and dragging highlights a contiguous g…

when I paste code in to a Vim document, the indentation gets all screwed up.

Try :set paste :set nopaste :set invpaste :help paste

Re: Coming Home to Vim

#60
post #54

A litte off topic. Much that I like vim I haven't found any plugin than can indent Javascript properly. To be honest whenever I write Javascript I just open up emacs. Is there something close to js-mode in vim?

(ITYM js2-mode) No.

I use this to indent my JS: http://www.vim.org/scripts/script.php?script_id=1936

You could use JSLint plugin to get more of the features, but I've never gotten it to feel like js2-mode.

Post reply on HN