Skip to content

Commit

Permalink
feat: <C-w>gf open file in new tab.
Browse files Browse the repository at this point in the history
  • Loading branch information
hotoo committed Sep 21, 2016
1 parent c107331 commit c92372d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# JSGF: imporved GF for JavaScript
# JSGF: imporved `gf` for JavaScript

Imporved JavaScript `gf` command.

Expand All @@ -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.
- `<C-w>gf` in normal mode: open file in new tab.

## Document

```
:help gf
```

## Options

Expand Down
7 changes: 4 additions & 3 deletions plugin/jsgf.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 <buffer> gf :call JSGF("<C-R><C-P>")<CR>
autocmd FileType javascript,json,typescript nmap <buffer> gf :call JSGF('<C-R><C-P>', 'e')<CR>
autocmd FileType javascript,json,typescript nmap <buffer> <C-w>gf :call JSGF('<C-R><C-P>', 'tabnew')<CR>

0 comments on commit c92372d

Please sign in to comment.