reformat file by external tool before writing file in vim
up vote
0
down vote
favorite
I want the vim to call ':!gn format BUILD.gn' when I write BUILD.gn file, my .vimrc is (version 1)
autocmd BufWritePre *.{gn,gni} call GnFormat()
function! GnForamt()
exec '!gn format %'
endfunction
But it can not work when I press ':w", it shows error message as
Error detected while processing BufWrite Autocommands for "*.gn":
"BUILD.gn" 67L, 1423C written
How to show more detail debug information and what's the correct method to call external format tool?
I also tried following method, but failed too (version 2)
autocmd BufWritePre *.{gn,gni} call GnFormat()
function! GnForamt()
exec '%!gn format --stdin'
endfunction
The output result of version 2 .vimrc of :11verbose w is
Executing BufWrite Autocommands for "*.{gn,gni}"
autocommand call GnFormat()
Error detected while processing BufWrite Autocommands for "*.{gn,gni}":
"BUILD.gn" 27L, 538C written
Executing BufWritePost Autocommands for "*"
autocommand cal s:record(expand('<abuf>', 1))
Executing BufWritePost Autocommands for "*"
autocommand call s:BufWritePostHook(expand('<afile>', 1))
And in the version 2, I can use :call GnForamt() manually to reformat the buffer without any error message.
Just know the reason
autocmd BufWritePre *.{gn,gni} call GnFormat()
function! GnFormat() " <--- typo of Format as Foramt
exec '%!gn format --stdin'
endfunction
vim
add a comment |
up vote
0
down vote
favorite
I want the vim to call ':!gn format BUILD.gn' when I write BUILD.gn file, my .vimrc is (version 1)
autocmd BufWritePre *.{gn,gni} call GnFormat()
function! GnForamt()
exec '!gn format %'
endfunction
But it can not work when I press ':w", it shows error message as
Error detected while processing BufWrite Autocommands for "*.gn":
"BUILD.gn" 67L, 1423C written
How to show more detail debug information and what's the correct method to call external format tool?
I also tried following method, but failed too (version 2)
autocmd BufWritePre *.{gn,gni} call GnFormat()
function! GnForamt()
exec '%!gn format --stdin'
endfunction
The output result of version 2 .vimrc of :11verbose w is
Executing BufWrite Autocommands for "*.{gn,gni}"
autocommand call GnFormat()
Error detected while processing BufWrite Autocommands for "*.{gn,gni}":
"BUILD.gn" 27L, 538C written
Executing BufWritePost Autocommands for "*"
autocommand cal s:record(expand('<abuf>', 1))
Executing BufWritePost Autocommands for "*"
autocommand call s:BufWritePostHook(expand('<afile>', 1))
And in the version 2, I can use :call GnForamt() manually to reformat the buffer without any error message.
Just know the reason
autocmd BufWritePre *.{gn,gni} call GnFormat()
function! GnFormat() " <--- typo of Format as Foramt
exec '%!gn format --stdin'
endfunction
vim
Shouldn't it be*.gn,*.gnias filetype?
– Doktor OSwaldo
Nov 8 at 7:05
It can changed to BUILD.gn, but still not workable, you can try it.
– Daniel YC Lin
Nov 8 at 7:14
don't worry*.{gn,gni}seems to work depending on your output. It is just new for me
– Doktor OSwaldo
Nov 8 at 7:18
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I want the vim to call ':!gn format BUILD.gn' when I write BUILD.gn file, my .vimrc is (version 1)
autocmd BufWritePre *.{gn,gni} call GnFormat()
function! GnForamt()
exec '!gn format %'
endfunction
But it can not work when I press ':w", it shows error message as
Error detected while processing BufWrite Autocommands for "*.gn":
"BUILD.gn" 67L, 1423C written
How to show more detail debug information and what's the correct method to call external format tool?
I also tried following method, but failed too (version 2)
autocmd BufWritePre *.{gn,gni} call GnFormat()
function! GnForamt()
exec '%!gn format --stdin'
endfunction
The output result of version 2 .vimrc of :11verbose w is
Executing BufWrite Autocommands for "*.{gn,gni}"
autocommand call GnFormat()
Error detected while processing BufWrite Autocommands for "*.{gn,gni}":
"BUILD.gn" 27L, 538C written
Executing BufWritePost Autocommands for "*"
autocommand cal s:record(expand('<abuf>', 1))
Executing BufWritePost Autocommands for "*"
autocommand call s:BufWritePostHook(expand('<afile>', 1))
And in the version 2, I can use :call GnForamt() manually to reformat the buffer without any error message.
Just know the reason
autocmd BufWritePre *.{gn,gni} call GnFormat()
function! GnFormat() " <--- typo of Format as Foramt
exec '%!gn format --stdin'
endfunction
vim
I want the vim to call ':!gn format BUILD.gn' when I write BUILD.gn file, my .vimrc is (version 1)
autocmd BufWritePre *.{gn,gni} call GnFormat()
function! GnForamt()
exec '!gn format %'
endfunction
But it can not work when I press ':w", it shows error message as
Error detected while processing BufWrite Autocommands for "*.gn":
"BUILD.gn" 67L, 1423C written
How to show more detail debug information and what's the correct method to call external format tool?
I also tried following method, but failed too (version 2)
autocmd BufWritePre *.{gn,gni} call GnFormat()
function! GnForamt()
exec '%!gn format --stdin'
endfunction
The output result of version 2 .vimrc of :11verbose w is
Executing BufWrite Autocommands for "*.{gn,gni}"
autocommand call GnFormat()
Error detected while processing BufWrite Autocommands for "*.{gn,gni}":
"BUILD.gn" 27L, 538C written
Executing BufWritePost Autocommands for "*"
autocommand cal s:record(expand('<abuf>', 1))
Executing BufWritePost Autocommands for "*"
autocommand call s:BufWritePostHook(expand('<afile>', 1))
And in the version 2, I can use :call GnForamt() manually to reformat the buffer without any error message.
Just know the reason
autocmd BufWritePre *.{gn,gni} call GnFormat()
function! GnFormat() " <--- typo of Format as Foramt
exec '%!gn format --stdin'
endfunction
vim
vim
edited Nov 8 at 7:53
asked Nov 8 at 3:28
Daniel YC Lin
4,44893963
4,44893963
Shouldn't it be*.gn,*.gnias filetype?
– Doktor OSwaldo
Nov 8 at 7:05
It can changed to BUILD.gn, but still not workable, you can try it.
– Daniel YC Lin
Nov 8 at 7:14
don't worry*.{gn,gni}seems to work depending on your output. It is just new for me
– Doktor OSwaldo
Nov 8 at 7:18
add a comment |
Shouldn't it be*.gn,*.gnias filetype?
– Doktor OSwaldo
Nov 8 at 7:05
It can changed to BUILD.gn, but still not workable, you can try it.
– Daniel YC Lin
Nov 8 at 7:14
don't worry*.{gn,gni}seems to work depending on your output. It is just new for me
– Doktor OSwaldo
Nov 8 at 7:18
Shouldn't it be
*.gn,*.gni as filetype?– Doktor OSwaldo
Nov 8 at 7:05
Shouldn't it be
*.gn,*.gni as filetype?– Doktor OSwaldo
Nov 8 at 7:05
It can changed to BUILD.gn, but still not workable, you can try it.
– Daniel YC Lin
Nov 8 at 7:14
It can changed to BUILD.gn, but still not workable, you can try it.
– Daniel YC Lin
Nov 8 at 7:14
don't worry
*.{gn,gni} seems to work depending on your output. It is just new for me– Doktor OSwaldo
Nov 8 at 7:18
don't worry
*.{gn,gni} seems to work depending on your output. It is just new for me– Doktor OSwaldo
Nov 8 at 7:18
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
try :debug w (see :h debug) or :13verbose w. See :h verbose and :h 'verbose'.
:[level]verbose will allow you to activate verbose mode for a single action
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
try :debug w (see :h debug) or :13verbose w. See :h verbose and :h 'verbose'.
:[level]verbose will allow you to activate verbose mode for a single action
add a comment |
up vote
0
down vote
accepted
try :debug w (see :h debug) or :13verbose w. See :h verbose and :h 'verbose'.
:[level]verbose will allow you to activate verbose mode for a single action
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
try :debug w (see :h debug) or :13verbose w. See :h verbose and :h 'verbose'.
:[level]verbose will allow you to activate verbose mode for a single action
try :debug w (see :h debug) or :13verbose w. See :h verbose and :h 'verbose'.
:[level]verbose will allow you to activate verbose mode for a single action
answered Nov 8 at 7:11
Doktor OSwaldo
3,524826
3,524826
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53201144%2freformat-file-by-external-tool-before-writing-file-in-vim%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Shouldn't it be
*.gn,*.gnias filetype?– Doktor OSwaldo
Nov 8 at 7:05
It can changed to BUILD.gn, but still not workable, you can try it.
– Daniel YC Lin
Nov 8 at 7:14
don't worry
*.{gn,gni}seems to work depending on your output. It is just new for me– Doktor OSwaldo
Nov 8 at 7:18