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
command-line echo
add a comment |
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
command-line echo
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
add a comment |
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
command-line echo
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
command-line echo
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
add a comment |
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
add a comment |
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 ^@).
Ohh I didn't realize this behaviour was specific toechom. Thanks.
– Steve Vermeulen
2 days ago
@SteveVermeulen No problem. Yeah I think the primary use case forechom, 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
add a comment |
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 ^@).
Ohh I didn't realize this behaviour was specific toechom. Thanks.
– Steve Vermeulen
2 days ago
@SteveVermeulen No problem. Yeah I think the primary use case forechom, 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
add a comment |
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 ^@).
Ohh I didn't realize this behaviour was specific toechom. Thanks.
– Steve Vermeulen
2 days ago
@SteveVermeulen No problem. Yeah I think the primary use case forechom, 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
add a comment |
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 ^@).
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 ^@).
edited 2 days ago
answered 2 days ago
B Layer
5,3271318
5,3271318
Ohh I didn't realize this behaviour was specific toechom. Thanks.
– Steve Vermeulen
2 days ago
@SteveVermeulen No problem. Yeah I think the primary use case forechom, 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
add a comment |
Ohh I didn't realize this behaviour was specific toechom. Thanks.
– Steve Vermeulen
2 days ago
@SteveVermeulen No problem. Yeah I think the primary use case forechom, 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
add a comment |
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.
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%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
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
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