Hacker News new | past | comments | ask | show | jobs | submit login

I guess it's also one thing to know them, and one thing to be comfortable typing them in a nonstop flow of text. My keystroke speed rarely changes from insert mode to control mode; vim commands have become an integral part of my typing process. I feel severely gimped whenever I can't use my vim controls.

As for knowing the number of lines you need to jump, either do :set number and be quick at math, or you can modify the numbers to be relative to your current line.

I took me probably a week to be able to actually get anything done in vim, and a month to prefer vim to anything else.

That being said, I know far more commands than the ones I listed. Those commands got me to my first month, though.




I think the number thing can be confusing, and it is hard to think in terms of 'delete the following 5 lines'. For those things I tend to use visual mode and highlight (still think keyboard-based selection is faster than with a mouse most times).

I also have a shortcut for a 3-way toggle using F2 - so I can either see absolute, relative or no line numbers at all. I don't use it much, but it can be handy at times.

    function! NumberToggle()
      if(g:numberstate == 0)
        set number
        let g:numberstate=1
      elseif(g:numberstate == 1)
        set relativenumber
        let g:numberstate=2
      else
        set nonumber
        set norelativenumber
        let g:numberstate=0
      endif
      set foldcolumn=0
    endfunc
    let g:numberstate=0
    nnoremap <F2> :call NumberToggle()<CR>


You can get rid of the global variable by testing the actual settings instead:

    function! NumberToggle()
        if (!&number && !&relativenumber)
            set number
            set norelativenumber
        elseif (&number && !&relativenumber)
            set relativenumber
        else
            set nonumber
            set norelativenumber
        endif
        set foldcolumn=0
    endfunc


Thanks! It was my first attempt writing a vim function, so wasn't exactly sure. This looks much better.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: