How to split stdout and stderr of shell command output cleanly and show the latter in Vim status line?










0















I use Vim as my dash board and monitor/update many tables with various external(filtering) commands, run from macros. They work terrifically, except the error output (not yet perfect, though I've resolved 80% of this message integration. See p.s. for the story for such application).



For example, the following table is for "I love coffee" game:



TYPE | STAT | NAME | GOAL | DONE | TODO | S1 | S2 | S3
drink | . | Latte | 250 | 178 | 72 | . | . | .
drink | . | Cocoa | 99 | 46 | 50 | . | 3 | .
drink | . | Mocha | 250 | 190 | 40 | 12 | 8 | .
drink | . | Espresso | 30 | 0 | 20 | 10 | . | .
drink | . | Iced Latte | 54 | 8 | 37 | . | . | 9
cake | . | Egg Tart | 25 | 15 | 4 | 6 | . | .
cake | . | Tiramisu | 36 | 6 | 20 | 4 | 6 | .
cake | . | Brûlée | 11 | 0 | 9 | . | 2 | .
cake | v | Pudding | 20 | 20 | 0 | . | . | .


I have the following macro in register s:



'oV}!order-update.pl 2>/tmp/vim.err ^M:if getfsize('/tmp/vim.err')>0|echo join(readfile('/tmp/vim.err'),"|")|endif ^M'o


(^M is the character ctrl-M),
which helps update the DONE and TODO columns when I've touched the quantity in Store1/2/3. (And if finished, will make a v check and move the line down to the top of historical area.)



When there is something wrong in the numbers of S1/S2/S3, the redirection 2> will spilt the stderr output from stdout output and save in vim.err file. (not to mess up the table)



The if...endif block will get the error output back and echo it to status line. It will print Store3 drink: 9 > 8 max when I put 9 in S3. (But S3 can hold a maximum of 8 drinks.)



My problem is that the last ex command line:



:if getfsize('/tmp/vim.err')>0|echo join(readfile('/tmp/vim.err'),"|")|endif


will be left in the status line if no error occur.



How can I improve it?




p.s.



Story of such an application



The above (simplified) example demonstrates how I use Vim as a quick spreadsheet, for many tables I update every day. The benefit is - I don't have to leave my favorite Vim.



With some syntax highlighting, Vim can present those tables in the way best preferable to my eyes. (depending on those values)



With related filters, every table can be correctly updated according to the values' dependency.



I've developed many syntax/filter pairs for various projects over the years. And recently I got aware that I've not yet integrate the filter's error messages into Vim's environment. Such messages will be randomly merged into the normal output and make a messed-up table. (with Vim's default setting shellredir=">%s 2>$1")



My intention is to collect filter's stderr messages and fit them in Vim's status line.



Some results have been achieved in my experiments:



  1. The "2>vim.err" specified in macro can overrule the default "2>&1" and split the stderr into the tempfile.


  2. The readfile() function is great to read in the whole file.


  3. The filter had better not exit with non-zero value for minor errors detected. Such value will make Vim do more things and raise a "Hit-enter" prompt.


And fitting the stderr messages smoothly in status line is my last piece of puzzle.










share|improve this question
























  • According to the suggestion of @IngoKarkat, this fix: :if getfsize('/tmp/vim.err')>0|echo join(readfile('/tmp/vim.err'),"|")|else|echo|endif will cleanly clear the code itself. A simple and perfect solution! (And thanks @romainl to put my code in the block with scrollbar. I didn't successfully try it out.)

    – Charles Jie
    Nov 14 '18 at 21:41















0















I use Vim as my dash board and monitor/update many tables with various external(filtering) commands, run from macros. They work terrifically, except the error output (not yet perfect, though I've resolved 80% of this message integration. See p.s. for the story for such application).



For example, the following table is for "I love coffee" game:



TYPE | STAT | NAME | GOAL | DONE | TODO | S1 | S2 | S3
drink | . | Latte | 250 | 178 | 72 | . | . | .
drink | . | Cocoa | 99 | 46 | 50 | . | 3 | .
drink | . | Mocha | 250 | 190 | 40 | 12 | 8 | .
drink | . | Espresso | 30 | 0 | 20 | 10 | . | .
drink | . | Iced Latte | 54 | 8 | 37 | . | . | 9
cake | . | Egg Tart | 25 | 15 | 4 | 6 | . | .
cake | . | Tiramisu | 36 | 6 | 20 | 4 | 6 | .
cake | . | Brûlée | 11 | 0 | 9 | . | 2 | .
cake | v | Pudding | 20 | 20 | 0 | . | . | .


I have the following macro in register s:



'oV}!order-update.pl 2>/tmp/vim.err ^M:if getfsize('/tmp/vim.err')>0|echo join(readfile('/tmp/vim.err'),"|")|endif ^M'o


(^M is the character ctrl-M),
which helps update the DONE and TODO columns when I've touched the quantity in Store1/2/3. (And if finished, will make a v check and move the line down to the top of historical area.)



When there is something wrong in the numbers of S1/S2/S3, the redirection 2> will spilt the stderr output from stdout output and save in vim.err file. (not to mess up the table)



The if...endif block will get the error output back and echo it to status line. It will print Store3 drink: 9 > 8 max when I put 9 in S3. (But S3 can hold a maximum of 8 drinks.)



My problem is that the last ex command line:



:if getfsize('/tmp/vim.err')>0|echo join(readfile('/tmp/vim.err'),"|")|endif


will be left in the status line if no error occur.



How can I improve it?




p.s.



Story of such an application



The above (simplified) example demonstrates how I use Vim as a quick spreadsheet, for many tables I update every day. The benefit is - I don't have to leave my favorite Vim.



With some syntax highlighting, Vim can present those tables in the way best preferable to my eyes. (depending on those values)



With related filters, every table can be correctly updated according to the values' dependency.



I've developed many syntax/filter pairs for various projects over the years. And recently I got aware that I've not yet integrate the filter's error messages into Vim's environment. Such messages will be randomly merged into the normal output and make a messed-up table. (with Vim's default setting shellredir=">%s 2>$1")



My intention is to collect filter's stderr messages and fit them in Vim's status line.



Some results have been achieved in my experiments:



  1. The "2>vim.err" specified in macro can overrule the default "2>&1" and split the stderr into the tempfile.


  2. The readfile() function is great to read in the whole file.


  3. The filter had better not exit with non-zero value for minor errors detected. Such value will make Vim do more things and raise a "Hit-enter" prompt.


And fitting the stderr messages smoothly in status line is my last piece of puzzle.










share|improve this question
























  • According to the suggestion of @IngoKarkat, this fix: :if getfsize('/tmp/vim.err')>0|echo join(readfile('/tmp/vim.err'),"|")|else|echo|endif will cleanly clear the code itself. A simple and perfect solution! (And thanks @romainl to put my code in the block with scrollbar. I didn't successfully try it out.)

    – Charles Jie
    Nov 14 '18 at 21:41













0












0








0








I use Vim as my dash board and monitor/update many tables with various external(filtering) commands, run from macros. They work terrifically, except the error output (not yet perfect, though I've resolved 80% of this message integration. See p.s. for the story for such application).



For example, the following table is for "I love coffee" game:



TYPE | STAT | NAME | GOAL | DONE | TODO | S1 | S2 | S3
drink | . | Latte | 250 | 178 | 72 | . | . | .
drink | . | Cocoa | 99 | 46 | 50 | . | 3 | .
drink | . | Mocha | 250 | 190 | 40 | 12 | 8 | .
drink | . | Espresso | 30 | 0 | 20 | 10 | . | .
drink | . | Iced Latte | 54 | 8 | 37 | . | . | 9
cake | . | Egg Tart | 25 | 15 | 4 | 6 | . | .
cake | . | Tiramisu | 36 | 6 | 20 | 4 | 6 | .
cake | . | Brûlée | 11 | 0 | 9 | . | 2 | .
cake | v | Pudding | 20 | 20 | 0 | . | . | .


I have the following macro in register s:



'oV}!order-update.pl 2>/tmp/vim.err ^M:if getfsize('/tmp/vim.err')>0|echo join(readfile('/tmp/vim.err'),"|")|endif ^M'o


(^M is the character ctrl-M),
which helps update the DONE and TODO columns when I've touched the quantity in Store1/2/3. (And if finished, will make a v check and move the line down to the top of historical area.)



When there is something wrong in the numbers of S1/S2/S3, the redirection 2> will spilt the stderr output from stdout output and save in vim.err file. (not to mess up the table)



The if...endif block will get the error output back and echo it to status line. It will print Store3 drink: 9 > 8 max when I put 9 in S3. (But S3 can hold a maximum of 8 drinks.)



My problem is that the last ex command line:



:if getfsize('/tmp/vim.err')>0|echo join(readfile('/tmp/vim.err'),"|")|endif


will be left in the status line if no error occur.



How can I improve it?




p.s.



Story of such an application



The above (simplified) example demonstrates how I use Vim as a quick spreadsheet, for many tables I update every day. The benefit is - I don't have to leave my favorite Vim.



With some syntax highlighting, Vim can present those tables in the way best preferable to my eyes. (depending on those values)



With related filters, every table can be correctly updated according to the values' dependency.



I've developed many syntax/filter pairs for various projects over the years. And recently I got aware that I've not yet integrate the filter's error messages into Vim's environment. Such messages will be randomly merged into the normal output and make a messed-up table. (with Vim's default setting shellredir=">%s 2>$1")



My intention is to collect filter's stderr messages and fit them in Vim's status line.



Some results have been achieved in my experiments:



  1. The "2>vim.err" specified in macro can overrule the default "2>&1" and split the stderr into the tempfile.


  2. The readfile() function is great to read in the whole file.


  3. The filter had better not exit with non-zero value for minor errors detected. Such value will make Vim do more things and raise a "Hit-enter" prompt.


And fitting the stderr messages smoothly in status line is my last piece of puzzle.










share|improve this question
















I use Vim as my dash board and monitor/update many tables with various external(filtering) commands, run from macros. They work terrifically, except the error output (not yet perfect, though I've resolved 80% of this message integration. See p.s. for the story for such application).



For example, the following table is for "I love coffee" game:



TYPE | STAT | NAME | GOAL | DONE | TODO | S1 | S2 | S3
drink | . | Latte | 250 | 178 | 72 | . | . | .
drink | . | Cocoa | 99 | 46 | 50 | . | 3 | .
drink | . | Mocha | 250 | 190 | 40 | 12 | 8 | .
drink | . | Espresso | 30 | 0 | 20 | 10 | . | .
drink | . | Iced Latte | 54 | 8 | 37 | . | . | 9
cake | . | Egg Tart | 25 | 15 | 4 | 6 | . | .
cake | . | Tiramisu | 36 | 6 | 20 | 4 | 6 | .
cake | . | Brûlée | 11 | 0 | 9 | . | 2 | .
cake | v | Pudding | 20 | 20 | 0 | . | . | .


I have the following macro in register s:



'oV}!order-update.pl 2>/tmp/vim.err ^M:if getfsize('/tmp/vim.err')>0|echo join(readfile('/tmp/vim.err'),"|")|endif ^M'o


(^M is the character ctrl-M),
which helps update the DONE and TODO columns when I've touched the quantity in Store1/2/3. (And if finished, will make a v check and move the line down to the top of historical area.)



When there is something wrong in the numbers of S1/S2/S3, the redirection 2> will spilt the stderr output from stdout output and save in vim.err file. (not to mess up the table)



The if...endif block will get the error output back and echo it to status line. It will print Store3 drink: 9 > 8 max when I put 9 in S3. (But S3 can hold a maximum of 8 drinks.)



My problem is that the last ex command line:



:if getfsize('/tmp/vim.err')>0|echo join(readfile('/tmp/vim.err'),"|")|endif


will be left in the status line if no error occur.



How can I improve it?




p.s.



Story of such an application



The above (simplified) example demonstrates how I use Vim as a quick spreadsheet, for many tables I update every day. The benefit is - I don't have to leave my favorite Vim.



With some syntax highlighting, Vim can present those tables in the way best preferable to my eyes. (depending on those values)



With related filters, every table can be correctly updated according to the values' dependency.



I've developed many syntax/filter pairs for various projects over the years. And recently I got aware that I've not yet integrate the filter's error messages into Vim's environment. Such messages will be randomly merged into the normal output and make a messed-up table. (with Vim's default setting shellredir=">%s 2>$1")



My intention is to collect filter's stderr messages and fit them in Vim's status line.



Some results have been achieved in my experiments:



  1. The "2>vim.err" specified in macro can overrule the default "2>&1" and split the stderr into the tempfile.


  2. The readfile() function is great to read in the whole file.


  3. The filter had better not exit with non-zero value for minor errors detected. Such value will make Vim do more things and raise a "Hit-enter" prompt.


And fitting the stderr messages smoothly in status line is my last piece of puzzle.







vim statusbar stderr






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 2 '18 at 7:06







Charles Jie

















asked Nov 14 '18 at 15:41









Charles JieCharles Jie

707




707












  • According to the suggestion of @IngoKarkat, this fix: :if getfsize('/tmp/vim.err')>0|echo join(readfile('/tmp/vim.err'),"|")|else|echo|endif will cleanly clear the code itself. A simple and perfect solution! (And thanks @romainl to put my code in the block with scrollbar. I didn't successfully try it out.)

    – Charles Jie
    Nov 14 '18 at 21:41

















  • According to the suggestion of @IngoKarkat, this fix: :if getfsize('/tmp/vim.err')>0|echo join(readfile('/tmp/vim.err'),"|")|else|echo|endif will cleanly clear the code itself. A simple and perfect solution! (And thanks @romainl to put my code in the block with scrollbar. I didn't successfully try it out.)

    – Charles Jie
    Nov 14 '18 at 21:41
















According to the suggestion of @IngoKarkat, this fix: :if getfsize('/tmp/vim.err')>0|echo join(readfile('/tmp/vim.err'),"|")|else|echo|endif will cleanly clear the code itself. A simple and perfect solution! (And thanks @romainl to put my code in the block with scrollbar. I didn't successfully try it out.)

– Charles Jie
Nov 14 '18 at 21:41





According to the suggestion of @IngoKarkat, this fix: :if getfsize('/tmp/vim.err')>0|echo join(readfile('/tmp/vim.err'),"|")|else|echo|endif will cleanly clear the code itself. A simple and perfect solution! (And thanks @romainl to put my code in the block with scrollbar. I didn't successfully try it out.)

– Charles Jie
Nov 14 '18 at 21:41












2 Answers
2






active

oldest

votes


















1














I don't think the "else|echo" is good solution to clear the status line all the time. It's ugly and not optimized for your macro.



Look at the content of your tmpfile vim.err, from stderr of your filter program. It should contains nothing if the filter doesn't see anything strange. Its empty content will help you clear the status line in the OK condition. I would rewrite your macro as (much simpler and cleaner):



'oV}!order-update.pl 2>/tmp/vim.err ^M:echo join(readfile('/tmp/vim.err'),"|") ^M'o


In addtion, I don't agree to Mr. Karkat's comment: "Macro kept in a register is only good for a single editing session". In fact, macros are kept in .viminfo and available from session to session. They will never disappear unless you assign empty to them. In my mind, macro is as powerful as mapping. And further, macro is more convenient (easier to create and maintain) than mapping. At least you can save the escaping nightmare of mapping. I would transcribe a macro to a mapping only when it's mature enough and globally useful.






share|improve this answer

























  • Thanks for your improvement! I prefer it. It's truly much cleaner. Between macro and mapping, my way is similar to yours. I don't define mappings as often as record and refine a macro. I guess macros help 80% of my editing job.

    – Charles Jie
    Dec 2 '18 at 4:58


















1














Keeping a macro in a register is fine for repetitive tasks done inside a single editing session. For things you need more often, I would define a proper mapping. With Vim, the "upgrade" is simple: The macro contents become the right-hand side of a :map command (with | becoming <Bar> and ^M becoming <CR>), which you put into your ~/.vimrc:



:nnoremap <Leader>s 'oV}!order-update.pl ...


If you use :nnoremap <silent>, the keys will not be printed, and you should only see the result of :echo.




To pragmatically fix your macro, just add an else|echo|endif to the end.






share|improve this answer























  • Thank you. Is "map-silent" the only rescue to make it quiet? (I've exhausted almost all the key combinations over the years. And I found macro is something similar but is easy to "overload" for different contexts/projects. It's why I prefer macro to mapping for this case. But if there is no rescue for macro, I may try to squeeze out some function keys for this purpose.)

    – Charles Jie
    Nov 14 '18 at 16:56











  • You can also try the "else echo" for your macro, or append | redraw if that alone isn't enough.

    – Ingo Karkat
    Nov 14 '18 at 19:53











  • I don't understand how you run out of mappings; you can have multiple keys on the left-hand side. So (some) mappings will get longer. Another alternative is a custom command; these usually are even longer, but you have command completion and no timeout on them.

    – Ingo Karkat
    Nov 14 '18 at 19:57











  • Thanks for your reminding. I didn't catch the point of the "else|echo" fix for the macro, but it does the trick! After a short nap and seeing your words, I tried to insert the "else|echo" part and found it works like a charm! It clears itself perfectly and as simple as I expect. Thank you both!

    – Charles Jie
    Nov 14 '18 at 21:02












  • For my understanding, such redundant "else|echo" part is an idiom of Vim for clearing the code left in status line. (quite special usage)

    – Charles Jie
    Nov 15 '18 at 11:06










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53303852%2fhow-to-split-stdout-and-stderr-of-shell-command-output-cleanly-and-show-the-latt%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














I don't think the "else|echo" is good solution to clear the status line all the time. It's ugly and not optimized for your macro.



Look at the content of your tmpfile vim.err, from stderr of your filter program. It should contains nothing if the filter doesn't see anything strange. Its empty content will help you clear the status line in the OK condition. I would rewrite your macro as (much simpler and cleaner):



'oV}!order-update.pl 2>/tmp/vim.err ^M:echo join(readfile('/tmp/vim.err'),"|") ^M'o


In addtion, I don't agree to Mr. Karkat's comment: "Macro kept in a register is only good for a single editing session". In fact, macros are kept in .viminfo and available from session to session. They will never disappear unless you assign empty to them. In my mind, macro is as powerful as mapping. And further, macro is more convenient (easier to create and maintain) than mapping. At least you can save the escaping nightmare of mapping. I would transcribe a macro to a mapping only when it's mature enough and globally useful.






share|improve this answer

























  • Thanks for your improvement! I prefer it. It's truly much cleaner. Between macro and mapping, my way is similar to yours. I don't define mappings as often as record and refine a macro. I guess macros help 80% of my editing job.

    – Charles Jie
    Dec 2 '18 at 4:58















1














I don't think the "else|echo" is good solution to clear the status line all the time. It's ugly and not optimized for your macro.



Look at the content of your tmpfile vim.err, from stderr of your filter program. It should contains nothing if the filter doesn't see anything strange. Its empty content will help you clear the status line in the OK condition. I would rewrite your macro as (much simpler and cleaner):



'oV}!order-update.pl 2>/tmp/vim.err ^M:echo join(readfile('/tmp/vim.err'),"|") ^M'o


In addtion, I don't agree to Mr. Karkat's comment: "Macro kept in a register is only good for a single editing session". In fact, macros are kept in .viminfo and available from session to session. They will never disappear unless you assign empty to them. In my mind, macro is as powerful as mapping. And further, macro is more convenient (easier to create and maintain) than mapping. At least you can save the escaping nightmare of mapping. I would transcribe a macro to a mapping only when it's mature enough and globally useful.






share|improve this answer

























  • Thanks for your improvement! I prefer it. It's truly much cleaner. Between macro and mapping, my way is similar to yours. I don't define mappings as often as record and refine a macro. I guess macros help 80% of my editing job.

    – Charles Jie
    Dec 2 '18 at 4:58













1












1








1







I don't think the "else|echo" is good solution to clear the status line all the time. It's ugly and not optimized for your macro.



Look at the content of your tmpfile vim.err, from stderr of your filter program. It should contains nothing if the filter doesn't see anything strange. Its empty content will help you clear the status line in the OK condition. I would rewrite your macro as (much simpler and cleaner):



'oV}!order-update.pl 2>/tmp/vim.err ^M:echo join(readfile('/tmp/vim.err'),"|") ^M'o


In addtion, I don't agree to Mr. Karkat's comment: "Macro kept in a register is only good for a single editing session". In fact, macros are kept in .viminfo and available from session to session. They will never disappear unless you assign empty to them. In my mind, macro is as powerful as mapping. And further, macro is more convenient (easier to create and maintain) than mapping. At least you can save the escaping nightmare of mapping. I would transcribe a macro to a mapping only when it's mature enough and globally useful.






share|improve this answer















I don't think the "else|echo" is good solution to clear the status line all the time. It's ugly and not optimized for your macro.



Look at the content of your tmpfile vim.err, from stderr of your filter program. It should contains nothing if the filter doesn't see anything strange. Its empty content will help you clear the status line in the OK condition. I would rewrite your macro as (much simpler and cleaner):



'oV}!order-update.pl 2>/tmp/vim.err ^M:echo join(readfile('/tmp/vim.err'),"|") ^M'o


In addtion, I don't agree to Mr. Karkat's comment: "Macro kept in a register is only good for a single editing session". In fact, macros are kept in .viminfo and available from session to session. They will never disappear unless you assign empty to them. In my mind, macro is as powerful as mapping. And further, macro is more convenient (easier to create and maintain) than mapping. At least you can save the escaping nightmare of mapping. I would transcribe a macro to a mapping only when it's mature enough and globally useful.







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 2 '18 at 4:29

























answered Dec 2 '18 at 4:24









椎名梨梨花椎名梨梨花

715




715












  • Thanks for your improvement! I prefer it. It's truly much cleaner. Between macro and mapping, my way is similar to yours. I don't define mappings as often as record and refine a macro. I guess macros help 80% of my editing job.

    – Charles Jie
    Dec 2 '18 at 4:58

















  • Thanks for your improvement! I prefer it. It's truly much cleaner. Between macro and mapping, my way is similar to yours. I don't define mappings as often as record and refine a macro. I guess macros help 80% of my editing job.

    – Charles Jie
    Dec 2 '18 at 4:58
















Thanks for your improvement! I prefer it. It's truly much cleaner. Between macro and mapping, my way is similar to yours. I don't define mappings as often as record and refine a macro. I guess macros help 80% of my editing job.

– Charles Jie
Dec 2 '18 at 4:58





Thanks for your improvement! I prefer it. It's truly much cleaner. Between macro and mapping, my way is similar to yours. I don't define mappings as often as record and refine a macro. I guess macros help 80% of my editing job.

– Charles Jie
Dec 2 '18 at 4:58













1














Keeping a macro in a register is fine for repetitive tasks done inside a single editing session. For things you need more often, I would define a proper mapping. With Vim, the "upgrade" is simple: The macro contents become the right-hand side of a :map command (with | becoming <Bar> and ^M becoming <CR>), which you put into your ~/.vimrc:



:nnoremap <Leader>s 'oV}!order-update.pl ...


If you use :nnoremap <silent>, the keys will not be printed, and you should only see the result of :echo.




To pragmatically fix your macro, just add an else|echo|endif to the end.






share|improve this answer























  • Thank you. Is "map-silent" the only rescue to make it quiet? (I've exhausted almost all the key combinations over the years. And I found macro is something similar but is easy to "overload" for different contexts/projects. It's why I prefer macro to mapping for this case. But if there is no rescue for macro, I may try to squeeze out some function keys for this purpose.)

    – Charles Jie
    Nov 14 '18 at 16:56











  • You can also try the "else echo" for your macro, or append | redraw if that alone isn't enough.

    – Ingo Karkat
    Nov 14 '18 at 19:53











  • I don't understand how you run out of mappings; you can have multiple keys on the left-hand side. So (some) mappings will get longer. Another alternative is a custom command; these usually are even longer, but you have command completion and no timeout on them.

    – Ingo Karkat
    Nov 14 '18 at 19:57











  • Thanks for your reminding. I didn't catch the point of the "else|echo" fix for the macro, but it does the trick! After a short nap and seeing your words, I tried to insert the "else|echo" part and found it works like a charm! It clears itself perfectly and as simple as I expect. Thank you both!

    – Charles Jie
    Nov 14 '18 at 21:02












  • For my understanding, such redundant "else|echo" part is an idiom of Vim for clearing the code left in status line. (quite special usage)

    – Charles Jie
    Nov 15 '18 at 11:06















1














Keeping a macro in a register is fine for repetitive tasks done inside a single editing session. For things you need more often, I would define a proper mapping. With Vim, the "upgrade" is simple: The macro contents become the right-hand side of a :map command (with | becoming <Bar> and ^M becoming <CR>), which you put into your ~/.vimrc:



:nnoremap <Leader>s 'oV}!order-update.pl ...


If you use :nnoremap <silent>, the keys will not be printed, and you should only see the result of :echo.




To pragmatically fix your macro, just add an else|echo|endif to the end.






share|improve this answer























  • Thank you. Is "map-silent" the only rescue to make it quiet? (I've exhausted almost all the key combinations over the years. And I found macro is something similar but is easy to "overload" for different contexts/projects. It's why I prefer macro to mapping for this case. But if there is no rescue for macro, I may try to squeeze out some function keys for this purpose.)

    – Charles Jie
    Nov 14 '18 at 16:56











  • You can also try the "else echo" for your macro, or append | redraw if that alone isn't enough.

    – Ingo Karkat
    Nov 14 '18 at 19:53











  • I don't understand how you run out of mappings; you can have multiple keys on the left-hand side. So (some) mappings will get longer. Another alternative is a custom command; these usually are even longer, but you have command completion and no timeout on them.

    – Ingo Karkat
    Nov 14 '18 at 19:57











  • Thanks for your reminding. I didn't catch the point of the "else|echo" fix for the macro, but it does the trick! After a short nap and seeing your words, I tried to insert the "else|echo" part and found it works like a charm! It clears itself perfectly and as simple as I expect. Thank you both!

    – Charles Jie
    Nov 14 '18 at 21:02












  • For my understanding, such redundant "else|echo" part is an idiom of Vim for clearing the code left in status line. (quite special usage)

    – Charles Jie
    Nov 15 '18 at 11:06













1












1








1







Keeping a macro in a register is fine for repetitive tasks done inside a single editing session. For things you need more often, I would define a proper mapping. With Vim, the "upgrade" is simple: The macro contents become the right-hand side of a :map command (with | becoming <Bar> and ^M becoming <CR>), which you put into your ~/.vimrc:



:nnoremap <Leader>s 'oV}!order-update.pl ...


If you use :nnoremap <silent>, the keys will not be printed, and you should only see the result of :echo.




To pragmatically fix your macro, just add an else|echo|endif to the end.






share|improve this answer













Keeping a macro in a register is fine for repetitive tasks done inside a single editing session. For things you need more often, I would define a proper mapping. With Vim, the "upgrade" is simple: The macro contents become the right-hand side of a :map command (with | becoming <Bar> and ^M becoming <CR>), which you put into your ~/.vimrc:



:nnoremap <Leader>s 'oV}!order-update.pl ...


If you use :nnoremap <silent>, the keys will not be printed, and you should only see the result of :echo.




To pragmatically fix your macro, just add an else|echo|endif to the end.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 14 '18 at 16:15









Ingo KarkatIngo Karkat

132k14148198




132k14148198












  • Thank you. Is "map-silent" the only rescue to make it quiet? (I've exhausted almost all the key combinations over the years. And I found macro is something similar but is easy to "overload" for different contexts/projects. It's why I prefer macro to mapping for this case. But if there is no rescue for macro, I may try to squeeze out some function keys for this purpose.)

    – Charles Jie
    Nov 14 '18 at 16:56











  • You can also try the "else echo" for your macro, or append | redraw if that alone isn't enough.

    – Ingo Karkat
    Nov 14 '18 at 19:53











  • I don't understand how you run out of mappings; you can have multiple keys on the left-hand side. So (some) mappings will get longer. Another alternative is a custom command; these usually are even longer, but you have command completion and no timeout on them.

    – Ingo Karkat
    Nov 14 '18 at 19:57











  • Thanks for your reminding. I didn't catch the point of the "else|echo" fix for the macro, but it does the trick! After a short nap and seeing your words, I tried to insert the "else|echo" part and found it works like a charm! It clears itself perfectly and as simple as I expect. Thank you both!

    – Charles Jie
    Nov 14 '18 at 21:02












  • For my understanding, such redundant "else|echo" part is an idiom of Vim for clearing the code left in status line. (quite special usage)

    – Charles Jie
    Nov 15 '18 at 11:06

















  • Thank you. Is "map-silent" the only rescue to make it quiet? (I've exhausted almost all the key combinations over the years. And I found macro is something similar but is easy to "overload" for different contexts/projects. It's why I prefer macro to mapping for this case. But if there is no rescue for macro, I may try to squeeze out some function keys for this purpose.)

    – Charles Jie
    Nov 14 '18 at 16:56











  • You can also try the "else echo" for your macro, or append | redraw if that alone isn't enough.

    – Ingo Karkat
    Nov 14 '18 at 19:53











  • I don't understand how you run out of mappings; you can have multiple keys on the left-hand side. So (some) mappings will get longer. Another alternative is a custom command; these usually are even longer, but you have command completion and no timeout on them.

    – Ingo Karkat
    Nov 14 '18 at 19:57











  • Thanks for your reminding. I didn't catch the point of the "else|echo" fix for the macro, but it does the trick! After a short nap and seeing your words, I tried to insert the "else|echo" part and found it works like a charm! It clears itself perfectly and as simple as I expect. Thank you both!

    – Charles Jie
    Nov 14 '18 at 21:02












  • For my understanding, such redundant "else|echo" part is an idiom of Vim for clearing the code left in status line. (quite special usage)

    – Charles Jie
    Nov 15 '18 at 11:06
















Thank you. Is "map-silent" the only rescue to make it quiet? (I've exhausted almost all the key combinations over the years. And I found macro is something similar but is easy to "overload" for different contexts/projects. It's why I prefer macro to mapping for this case. But if there is no rescue for macro, I may try to squeeze out some function keys for this purpose.)

– Charles Jie
Nov 14 '18 at 16:56





Thank you. Is "map-silent" the only rescue to make it quiet? (I've exhausted almost all the key combinations over the years. And I found macro is something similar but is easy to "overload" for different contexts/projects. It's why I prefer macro to mapping for this case. But if there is no rescue for macro, I may try to squeeze out some function keys for this purpose.)

– Charles Jie
Nov 14 '18 at 16:56













You can also try the "else echo" for your macro, or append | redraw if that alone isn't enough.

– Ingo Karkat
Nov 14 '18 at 19:53





You can also try the "else echo" for your macro, or append | redraw if that alone isn't enough.

– Ingo Karkat
Nov 14 '18 at 19:53













I don't understand how you run out of mappings; you can have multiple keys on the left-hand side. So (some) mappings will get longer. Another alternative is a custom command; these usually are even longer, but you have command completion and no timeout on them.

– Ingo Karkat
Nov 14 '18 at 19:57





I don't understand how you run out of mappings; you can have multiple keys on the left-hand side. So (some) mappings will get longer. Another alternative is a custom command; these usually are even longer, but you have command completion and no timeout on them.

– Ingo Karkat
Nov 14 '18 at 19:57













Thanks for your reminding. I didn't catch the point of the "else|echo" fix for the macro, but it does the trick! After a short nap and seeing your words, I tried to insert the "else|echo" part and found it works like a charm! It clears itself perfectly and as simple as I expect. Thank you both!

– Charles Jie
Nov 14 '18 at 21:02






Thanks for your reminding. I didn't catch the point of the "else|echo" fix for the macro, but it does the trick! After a short nap and seeing your words, I tried to insert the "else|echo" part and found it works like a charm! It clears itself perfectly and as simple as I expect. Thank you both!

– Charles Jie
Nov 14 '18 at 21:02














For my understanding, such redundant "else|echo" part is an idiom of Vim for clearing the code left in status line. (quite special usage)

– Charles Jie
Nov 15 '18 at 11:06





For my understanding, such redundant "else|echo" part is an idiom of Vim for clearing the code left in status line. (quite special usage)

– Charles Jie
Nov 15 '18 at 11:06

















draft saved

draft discarded
















































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.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53303852%2fhow-to-split-stdout-and-stderr-of-shell-command-output-cleanly-and-show-the-latt%23new-answer', 'question_page');

);

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







Popular posts from this blog

Top Tejano songwriter Luis Silva dead of heart attack at 64

ReactJS Fetched API data displays live - need Data displayed static

政党