4 ms·
Hah, I didn't think of that! Just before reading this comment I was working along in the editor, furiously pressing j/k. I'll put this to use immediately.
by bfwi 12y ago
Hah, I didn't think of that! Just before reading this comment I was working along in the editor, furiously pressing j/k. I'll put this to use immediately.
- bosie 12y agomight want to switch to relative line numbers. makes using 12j/k much easier in my experience.
- blueblob 12y agoor alternatively try the easymotion plugin[1] which you press <leader><leader>j (or whatever you map it to) and then it will highlight each potential line with a letter that you press to go to that line. j is one of the worst examples, it's nice if you are doing a dw so you don't have to count the words, you would just do d<leader><leader><motion> and it will highlight to the potential places. [1] https://github.com/Lokaltog/vim-easymotion https://github.com/Lokaltog/vim-easymotion
- jaredmcateer 12y agoIn your vimrc add the following (version 7.3+): set number set relativenumber This turns your line numbers into a hybrid mode that show the numbers relative to your cursor and the actual line number your cursor is currently on.
- steveklabnik 12y agoThat is way cooler than my old 'focus' hack. Thank you!
- mediocrejoker 12y agoThis doesn't work for me in 7.3.429-2ubuntu2.1. It still shows 0 for the line you're currently on.
- e12e 12y agoYikes! The continually changing numbers drives me crazy. Thanks for the tip, but I think I'll stick with just using ":13" to go to line #13... I guess there is some benefit if you do a lot of yanking/cutting based on lines, rather than some magic matching or such. But for now, relative line numbers is not for me. For (a little) more, see: http://vim.wikia.com/wiki/Jump_to_a_line_number http://vim.wikia.com/wiki/Jump_to_a_line_number
- dllthomas 12y agoGenerally in vim, if you're pressing a key over and over, that's a smell that there's room for improvement there. In addition to counting motions, other great options for getting around include: % jump to the matching brace/bracket/paren ( jump back a "sentence" ) jump forward a "sentence" { jump back a "paragraph" } jump forward a "paragraph" Also, getting around by searching can be hugely worthwhile.
- rbonvall 12y agoAlso: n jump to the next occurrence of the last search N " " " previous " " " " " " * jump to the next occurrence of the word under cursor # " " " previous " " " " " "
- dllthomas 12y agoYes! Also, ^R^W (ctrl-r, ctrl-w) when you're at the : prompt will drop in the current word under the cursor. Which is also quite useful in keybindings.
- Anthony-G 12y agoThanks. That's a great tip. I've always yanked the word that I wanted and then used Ctrl-R" to paste it on Vim's command line. This is much better. I'm now off to read "cmdline.txt" (:help Command-line). BTW, I just accidentally closed my browser tab (latest version of Firefox) by hitting Ctrl-W when I wanted to delete the previous word in this textbox. That used to drive me mad but when Firefox restored the tab, it also restored the text I'd typed. :)