5 ms·
I've been using Vim for about 5 years now. I started because I needed an editor that supported syntax highlighting and auto-indent to work on the university ser
by merijnv 16y ago
I've been using Vim for about 5 years now. I started because I needed an editor that supported syntax highlighting and auto-indent to work on the university servers over SSH.
It took (still takes) a lot of time to learn Vim. At first I used it as notepad with syntax-highlighting with auto-indent. That is, I immediately entered insert-mode and kept in there for as long as I could. But slowly I've started to learn myself how to truly use Vim. Nowadays I try and exit insert mode as quickly as possible (sometimes after typing just one or two letters).
Every once in a while I stop and reflect on things I do very often, look up ways to do them faster and then try and train those ways to be a habit. I learned most of these things from Bram Moolenaar's presentation "Seven habits of effective editing" (http://www.moolenaar.net/habits.pdf http://www.moolenaar.net/habits.pdf and http://video.google.com/videoplay?docid=2538831956647446078 http://video.google.com/videoplay?docid=2538831956647446078) most of this talk probably holds for emacs too.
Examples: when I need to rewrite a function arguments nowadays I just type "ci(" which does Change Inner parenthesis, it deletes all text between the enclosing parenthesis and puts me in insert mode to start typing. If I need to move more then 5 lines down I use incremental search instead of arrows/hjkl to move around. If I need to move to the end of a line I use $ (goto end of line) or A (append after end of line). If I need to go to the middle I'll use other shortcuts.
Vim has billions of ways to move around and select text for editing. Learning to use those relevant to your way of working is crucial if you want Vim effectively instead of annoying form of non-modal editor.
As for making Vim useful to you, I don't think anyone can tell you how to do this. You need to make it fit your style of working. Which means, trying, figuring out what bothers you and steal what works from others. Most of these example .vimrc's that people post do not include comments on what the options do, which makes this hard. I commented mine but it is rather sparse and I don't have a place to dump it at the moment to show you, unfortunately.
- younata 16y agoI'm curious. I've been using vim for not that long (but long enough that it's now my main editor). What all shortcuts exist for getting to the middle of a line?
- eel 16y agoYou can use 40| to go to the 40th column of a line. I typically use e or b to jump by words to reach the middle of a line. You can also 5e to jump by 5 words for instance too. I would be curious to know if there are other shortcuts for doing this too though.
- vilya 16y agoYou can use repeat counts with the cursor movement commands. For example, 40h will move your cursor 40 characters to the right; or 5w will move it forward 5 words. Alternatively you can use the search commands, '/' (forward search) or '?' (backwards search) with the text at the middle of the line as your search string.
- randallsquared 16y agogm jumps to the middle of the screen in the current line. [Edit: here's a nice cheatsheet of them: http://www.digilife.be/quickreferences/qrc/vim%20quick%20reference%20card.pdf http://www.digilife.be/quickreferences/qrc/vim%20quick%20ref... ]
- tdfx 16y agoI find myself using fX (find character X) often, where X is a character at the position I want to start editing. When I'm editing string parameters of a function I'm calling, I use di' / di" a lot (moves to first ' / ", deletes inside content, and drops to insert mode).
- tdfx 16y agoWhen I first started with vim, I immediately downloaded every possible plugin I ever thought I'd ever use, along with a bunch of complicated scripts that I added to my .vimrc, with hundreds of different options I copied from others' .vimrc files. As I learned vim, I learned to appreciate its simplicity and now keep my config at the minimum possible deviation from default as I can tolerate. My .vimrc is fairly spartan (http://github.com/tomhsx/homedir/blob/master/.vimrc http://github.com/tomhsx/homedir/blob/master/.vimrc) and the only plugins I use are ctags, pyflakes, and shortcuts for F6/F7/F8 to debug/execute python scripts.