How to have the echo command process newline characters?











up vote
1
down vote

favorite












I find that when running :echo message with a message variable that contains newlines, it displays the newline character as ^@. Often I'd prefer it to actually be split on a new line though. Do I have to split up the string manually and then make multiple calls to echo or is there a simpler way to do that?



edit:
Here's an example that reproduces what I'm talking about: :echom "foonbar". I'm running gvim on windows










share|improve this question
























  • Can you be more specific about those newlines. Where is the text coming from. Are you on *nix or Windows? (Can't be regular, multi-line Vim text because that should work just fine.)
    – B Layer
    2 days ago












  • Ok I updated the question
    – Steve Vermeulen
    2 days ago















up vote
1
down vote

favorite












I find that when running :echo message with a message variable that contains newlines, it displays the newline character as ^@. Often I'd prefer it to actually be split on a new line though. Do I have to split up the string manually and then make multiple calls to echo or is there a simpler way to do that?



edit:
Here's an example that reproduces what I'm talking about: :echom "foonbar". I'm running gvim on windows










share|improve this question
























  • Can you be more specific about those newlines. Where is the text coming from. Are you on *nix or Windows? (Can't be regular, multi-line Vim text because that should work just fine.)
    – B Layer
    2 days ago












  • Ok I updated the question
    – Steve Vermeulen
    2 days ago













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I find that when running :echo message with a message variable that contains newlines, it displays the newline character as ^@. Often I'd prefer it to actually be split on a new line though. Do I have to split up the string manually and then make multiple calls to echo or is there a simpler way to do that?



edit:
Here's an example that reproduces what I'm talking about: :echom "foonbar". I'm running gvim on windows










share|improve this question















I find that when running :echo message with a message variable that contains newlines, it displays the newline character as ^@. Often I'd prefer it to actually be split on a new line though. Do I have to split up the string manually and then make multiple calls to echo or is there a simpler way to do that?



edit:
Here's an example that reproduces what I'm talking about: :echom "foonbar". I'm running gvim on windows







command-line echo






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago

























asked 2 days ago









Steve Vermeulen

85779




85779












  • Can you be more specific about those newlines. Where is the text coming from. Are you on *nix or Windows? (Can't be regular, multi-line Vim text because that should work just fine.)
    – B Layer
    2 days ago












  • Ok I updated the question
    – Steve Vermeulen
    2 days ago


















  • Can you be more specific about those newlines. Where is the text coming from. Are you on *nix or Windows? (Can't be regular, multi-line Vim text because that should work just fine.)
    – B Layer
    2 days ago












  • Ok I updated the question
    – Steve Vermeulen
    2 days ago
















Can you be more specific about those newlines. Where is the text coming from. Are you on *nix or Windows? (Can't be regular, multi-line Vim text because that should work just fine.)
– B Layer
2 days ago






Can you be more specific about those newlines. Where is the text coming from. Are you on *nix or Windows? (Can't be regular, multi-line Vim text because that should work just fine.)
– B Layer
2 days ago














Ok I updated the question
– Steve Vermeulen
2 days ago




Ok I updated the question
– Steve Vermeulen
2 days ago










1 Answer
1






active

oldest

votes

















up vote
3
down vote



accepted










You originally mention :echo but based on your example it's :echom that is causing you issues so assuming that's right...



Some choices depending on your specific needs (e.g. do you care about the message being saved to the message history)...



:echo "foonbar"

:echon "foonbar"

:echom "foo" | echom "bar"


All of these will produce



foo
bar


Likely due to it's primary purpose being to print messages to be read by the user interactively, echom parses things a bit differently from the others. "Unprintable characters are displayed not interpreted". (Similar to the strtrans() function which also prints newlines as ^@).






share|improve this answer























  • Ohh I didn't realize this behaviour was specific to echom. Thanks.
    – Steve Vermeulen
    2 days ago










  • @SteveVermeulen No problem. Yeah I think the primary use case for echom, in contrast to the others, is real-time display of short messages for users. Thus you get qualities like avoiding non-printing chars and discouraging multi-line output.
    – B Layer
    2 days ago













Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "599"
};
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',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2fvi.stackexchange.com%2fquestions%2f18203%2fhow-to-have-the-echo-command-process-newline-characters%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
3
down vote



accepted










You originally mention :echo but based on your example it's :echom that is causing you issues so assuming that's right...



Some choices depending on your specific needs (e.g. do you care about the message being saved to the message history)...



:echo "foonbar"

:echon "foonbar"

:echom "foo" | echom "bar"


All of these will produce



foo
bar


Likely due to it's primary purpose being to print messages to be read by the user interactively, echom parses things a bit differently from the others. "Unprintable characters are displayed not interpreted". (Similar to the strtrans() function which also prints newlines as ^@).






share|improve this answer























  • Ohh I didn't realize this behaviour was specific to echom. Thanks.
    – Steve Vermeulen
    2 days ago










  • @SteveVermeulen No problem. Yeah I think the primary use case for echom, in contrast to the others, is real-time display of short messages for users. Thus you get qualities like avoiding non-printing chars and discouraging multi-line output.
    – B Layer
    2 days ago

















up vote
3
down vote



accepted










You originally mention :echo but based on your example it's :echom that is causing you issues so assuming that's right...



Some choices depending on your specific needs (e.g. do you care about the message being saved to the message history)...



:echo "foonbar"

:echon "foonbar"

:echom "foo" | echom "bar"


All of these will produce



foo
bar


Likely due to it's primary purpose being to print messages to be read by the user interactively, echom parses things a bit differently from the others. "Unprintable characters are displayed not interpreted". (Similar to the strtrans() function which also prints newlines as ^@).






share|improve this answer























  • Ohh I didn't realize this behaviour was specific to echom. Thanks.
    – Steve Vermeulen
    2 days ago










  • @SteveVermeulen No problem. Yeah I think the primary use case for echom, in contrast to the others, is real-time display of short messages for users. Thus you get qualities like avoiding non-printing chars and discouraging multi-line output.
    – B Layer
    2 days ago















up vote
3
down vote



accepted







up vote
3
down vote



accepted






You originally mention :echo but based on your example it's :echom that is causing you issues so assuming that's right...



Some choices depending on your specific needs (e.g. do you care about the message being saved to the message history)...



:echo "foonbar"

:echon "foonbar"

:echom "foo" | echom "bar"


All of these will produce



foo
bar


Likely due to it's primary purpose being to print messages to be read by the user interactively, echom parses things a bit differently from the others. "Unprintable characters are displayed not interpreted". (Similar to the strtrans() function which also prints newlines as ^@).






share|improve this answer














You originally mention :echo but based on your example it's :echom that is causing you issues so assuming that's right...



Some choices depending on your specific needs (e.g. do you care about the message being saved to the message history)...



:echo "foonbar"

:echon "foonbar"

:echom "foo" | echom "bar"


All of these will produce



foo
bar


Likely due to it's primary purpose being to print messages to be read by the user interactively, echom parses things a bit differently from the others. "Unprintable characters are displayed not interpreted". (Similar to the strtrans() function which also prints newlines as ^@).







share|improve this answer














share|improve this answer



share|improve this answer








edited 2 days ago

























answered 2 days ago









B Layer

5,3271318




5,3271318












  • Ohh I didn't realize this behaviour was specific to echom. Thanks.
    – Steve Vermeulen
    2 days ago










  • @SteveVermeulen No problem. Yeah I think the primary use case for echom, in contrast to the others, is real-time display of short messages for users. Thus you get qualities like avoiding non-printing chars and discouraging multi-line output.
    – B Layer
    2 days ago




















  • Ohh I didn't realize this behaviour was specific to echom. Thanks.
    – Steve Vermeulen
    2 days ago










  • @SteveVermeulen No problem. Yeah I think the primary use case for echom, in contrast to the others, is real-time display of short messages for users. Thus you get qualities like avoiding non-printing chars and discouraging multi-line output.
    – B Layer
    2 days ago


















Ohh I didn't realize this behaviour was specific to echom. Thanks.
– Steve Vermeulen
2 days ago




Ohh I didn't realize this behaviour was specific to echom. Thanks.
– Steve Vermeulen
2 days ago












@SteveVermeulen No problem. Yeah I think the primary use case for echom, in contrast to the others, is real-time display of short messages for users. Thus you get qualities like avoiding non-printing chars and discouraging multi-line output.
– B Layer
2 days ago






@SteveVermeulen No problem. Yeah I think the primary use case for echom, in contrast to the others, is real-time display of short messages for users. Thus you get qualities like avoiding non-printing chars and discouraging multi-line output.
– B Layer
2 days ago




















draft saved

draft discarded




















































Thanks for contributing an answer to Vi and Vim Stack Exchange!


  • 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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fvi.stackexchange.com%2fquestions%2f18203%2fhow-to-have-the-echo-command-process-newline-characters%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

Plaza Victoria

Brian Clough

Cáceres