forked from vscode-neovim/vscode-neovim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vscode-file-commands.vim
63 lines (51 loc) · 2.26 KB
/
vscode-file-commands.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
function! s:editOrNew(...)
let file = a:1
let bang = a:2
if empty(file)
if bang ==# '!'
call VSCodeNotify('workbench.action.files.revert')
else
call VSCodeNotify('workbench.action.quickOpen')
endif
else
" Last arg is to close previous file, e.g. e! ~/blah.txt will open blah.txt instead the current file
call VSCodeExtensionNotify('open-file', expand(file), bang ==# '!' ? 1 : 0)
endif
endfunction
function! s:saveAndClose() abort
call VSCodeCall('workbench.action.files.save')
call VSCodeNotify('workbench.action.closeActiveEditor')
endfunction
function! s:saveAllAndClose() abort
call VSCodeCall('workbench.action.files.saveAll')
call VSCodeNotify('workbench.action.closeAllEditors')
endfunction
" command! -bang -nargs=? Edit call VSCodeCall('workbench.action.quickOpen')
command! -complete=file -bang -nargs=? Edit call <SID>editOrNew(<q-args>, <q-bang>)
command! -bang -nargs=? Ex call <SID>editOrNew(<q-args>, <q-bang>)
command! -bang Enew call <SID>editOrNew('__vscode_new__', <q-bang>)
command! -bang Find call VSCodeNotify('workbench.action.quickOpen')
command! -complete=file -bang -nargs=? Write if <q-bang> ==# '!' | call VSCodeNotify('workbench.action.files.saveAs') | else | call VSCodeNotify('workbench.action.files.save') | endif
command! -bang Saveas call VSCodeNotify('workbench.action.files.saveAs')
command! -bang Wall call VSCodeNotify('workbench.action.files.saveAll')
command! -bang Quit if <q-bang> ==# '!' | call VSCodeNotify('workbench.action.revertAndCloseActiveEditor') | else | call VSCodeNotify('workbench.action.closeActiveEditor') | endif
command! -bang Wq call <SID>saveAndClose()
command! -bang Xit call <SID>saveAndClose()
command! -bang Qall call VSCodeNotify('workbench.action.closeAllEditors')
command! -bang Wqall call <SID>saveAllAndClose()
command! -bang Xall call <SID>saveAllAndClose()
AlterCommand e[dit] Edit
AlterCommand ex Ex
AlterCommand ene[w] Enew
AlterCommand fin[d] Find
AlterCommand w[rite] Write
AlterCommand sav[eas] Saveas
AlterCommand wa[ll] Wall
AlterCommand q[uit] Quit
AlterCommand wq Wq
AlterCommand x[it] Xit
AlterCommand qa[ll] Qall
AlterCommand wqa[ll] Wqall
AlterCommand xa[ll] Xall
nnoremap ZZ <Cmd>Wq<CR>
nnoremap ZQ <Cmd>Quit!<CR>