Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If only working with multiple files was easier... what are you guys using these days ?

[edit]

Also, one thing that shows how Vim is oriented towards opening and closing it all time is that preventing acidental quitting is quite hard to achieve (only with hacks..)



I've aliased vim -> "vim -p" which opens files into multiple tabs when passed as arguments.

I've rebound the arrow keys to switch and move tabs and buffers.

* up/down: previous/next buffer

* left/right: previous/next tab

* shift left/right: move tab to left or right

    inoremap <Up> <esc>:bprev<cr>
    inoremap <Down> <esc>:bnext<cr>
    inoremap <Left> <esc>:tabprev<cr>
    inoremap <Right> <esc>:tabnext<cr>
    noremap <Up> :bprev<cr>
    noremap <Down> :bnext<cr>
    noremap <Left> :tabprev<cr>
    noremap <Right> :tabnext<cr>
    nnoremap <silent> <S-Left> :execute 'silent! tabmove ' . (tabpagenr()-2)<CR>
    nnoremap <silent> <S-Right> :execute 'silent! tabmove ' . tabpagenr()<CR>
As for working with multiple files easier when vim's already open, it's a combination of Command-T, Buffer Explorer, and NERD tree.


The only vim plugin I use: http://www.vim.org/scripts/script.php?script_id=1664

With a few mappings:

    noremap <leader>b :ls<cr>:buffer 
    noremap <C-a> :b#<cr>
    noremap <C-h> :bprev<cr>
    noremap <C-l> :bnext<cr>


:bn [buffer next] :bp [buffer previous]

:bn is mapped to backslash on my installation.

:b <tab> for a list of all open files where you can pick the one you want to switch to. Mapped to ",." on my machine.

vim might have its problems. But buffer switching isn't one, for me.


How could anyone use :bn and :bp? Its 4 keypresses!! :) Contrast with ctrl-tab.


What do you call "accidental quitting"?


If you have two windows, :q closes the current window, and most people do that all the time, for removing buffers from the view. But if you only have one window and run that, with the intention of dumping the buffer or simply by mistake, your Vim is closed...




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

Search: