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

And to open a file under the cursor in a tab you can use:

  <C-w>gF
I map it to F9 along with a :tabm to make the new tab the last one in the list:

  nmap <F9> <C-W>gF:tabm<CR>
It's worth noting that if the filename has a colon followed by a line number on the end of it, your cursor will be placed on that line. E.g, <F9> with the cursor on the following:

  ~/.vimrc:40
Would open ~/.vimrc in a new tab, make it the last tab and place your cursor on line 40.

Grep and ack (and I'm sure other tools) use this line number format in their output when searching across multiple files. I often make use of this by piping the output of such a command into a new vim buffer:

  grep -Hnri 'some string or other' * | vim -
Then I use vim to search, further filter and open the files in tabs with my <F9> mapping, jumping straight to the specific line that matched my original search.


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

Search: