From c92372d4e2621e21ebb7fb5b0252a0e837873c8b Mon Sep 17 00:00:00 2001 From: hotoo Date: Wed, 21 Sep 2016 15:20:52 +0800 Subject: [PATCH] feat: gf open file in new tab. --- README.md | 15 +++++++++++---- plugin/jsgf.vim | 7 ++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3336345..e191fdd 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# JSGF: imporved GF for JavaScript +# JSGF: imporved `gf` for JavaScript Imporved JavaScript `gf` command. @@ -9,16 +9,23 @@ Support: * React (*.jsx) * TypeScript (*.ts, *.tsx) -## INSTALL +## Installation Vundle: ```viml Plugin 'hotoo/jsgf.vim' ``` -## USAGE +## Usage -`gf` in normal mode. +- `gf` in normal mode: goto file in current buffer. +- `gf` in normal mode: open file in new tab. + +## Document + +``` +:help gf +``` ## Options diff --git a/plugin/jsgf.vim b/plugin/jsgf.vim index e12b3bf..2afcd22 100644 --- a/plugin/jsgf.vim +++ b/plugin/jsgf.vim @@ -35,7 +35,7 @@ function! FindFileOrDir(filename) return '' endfunction -function! JSGF(filepath) +function! JSGF(filepath, open) let filename = a:filepath if isdirectory(filename) let pkg_file = filename . '/package.json' @@ -77,8 +77,9 @@ function! JSGF(filepath) return endif - execute 'e' filename + execute a:open filename endfunction autocmd FileType javascript,json,typescript call InitJSGF() -autocmd FileType javascript,json,typescript nmap gf :call JSGF("") +autocmd FileType javascript,json,typescript nmap gf :call JSGF('', 'e') +autocmd FileType javascript,json,typescript nmap gf :call JSGF('', 'tabnew')