Hard line wrapping in vim without joining in insert mode
Very new to vim. Found a useful post here that explains how to get automatic hard line breaks while in insert mode.
This had unintended consequences. For example, suppose I start a new .txt file. While in insert mode, I type
a
Still in insert mode, I hit return and type 'b'. What appears is not
a
b
but
a b
When I set
set: formatoptions-=a
This unintended behavior stops, as do the intended line breaks.
I'd like to keep the latter without the former. There seemed to be a related question that focuses on the same issue, but for re-formatting existing text. Any help would be greatly appreciated. Thanks!
vim text-formatting word-wrap
add a comment |
Very new to vim. Found a useful post here that explains how to get automatic hard line breaks while in insert mode.
This had unintended consequences. For example, suppose I start a new .txt file. While in insert mode, I type
a
Still in insert mode, I hit return and type 'b'. What appears is not
a
b
but
a b
When I set
set: formatoptions-=a
This unintended behavior stops, as do the intended line breaks.
I'd like to keep the latter without the former. There seemed to be a related question that focuses on the same issue, but for re-formatting existing text. Any help would be greatly appreciated. Thanks!
vim text-formatting word-wrap
add a comment |
Very new to vim. Found a useful post here that explains how to get automatic hard line breaks while in insert mode.
This had unintended consequences. For example, suppose I start a new .txt file. While in insert mode, I type
a
Still in insert mode, I hit return and type 'b'. What appears is not
a
b
but
a b
When I set
set: formatoptions-=a
This unintended behavior stops, as do the intended line breaks.
I'd like to keep the latter without the former. There seemed to be a related question that focuses on the same issue, but for re-formatting existing text. Any help would be greatly appreciated. Thanks!
vim text-formatting word-wrap
Very new to vim. Found a useful post here that explains how to get automatic hard line breaks while in insert mode.
This had unintended consequences. For example, suppose I start a new .txt file. While in insert mode, I type
a
Still in insert mode, I hit return and type 'b'. What appears is not
a
b
but
a b
When I set
set: formatoptions-=a
This unintended behavior stops, as do the intended line breaks.
I'd like to keep the latter without the former. There seemed to be a related question that focuses on the same issue, but for re-formatting existing text. Any help would be greatly appreciated. Thanks!
vim text-formatting word-wrap
vim text-formatting word-wrap
asked Dec 13 '18 at 2:45
GregGreg
31
31
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Auto-formatting first sounds like a great feature, but it has many caveats, so I personally find it helpful only for very few editing tasks.
:help auto-format
offers good advice to make this workable. In particular:
- You need to properly define paragraphs. The simplest is paragraphs that are
separated by a blank line. When there is no separating blank line, consider
using the 'w' flag and adding a space at the end of each line in the
paragraphs except the last one.
So, :setlocal formatoptions+=w
and then it'll work as you expect. (But each line inside a paragraph will end with a trailing space!)
Thank you very much!! Tried this and it worked great. The auto-format documentation was also very helpful -- will check there before asking questions in the future. Thanks again!
– Greg
Dec 15 '18 at 22:20
Alright, nice. Please don't forget to accept the answer (by clicking on the outlined checkmark next to it)!
– Ingo Karkat
Dec 15 '18 at 22:25
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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
});
}
});
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%2fsuperuser.com%2fquestions%2f1383169%2fhard-line-wrapping-in-vim-without-joining-in-insert-mode%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
Auto-formatting first sounds like a great feature, but it has many caveats, so I personally find it helpful only for very few editing tasks.
:help auto-format
offers good advice to make this workable. In particular:
- You need to properly define paragraphs. The simplest is paragraphs that are
separated by a blank line. When there is no separating blank line, consider
using the 'w' flag and adding a space at the end of each line in the
paragraphs except the last one.
So, :setlocal formatoptions+=w
and then it'll work as you expect. (But each line inside a paragraph will end with a trailing space!)
Thank you very much!! Tried this and it worked great. The auto-format documentation was also very helpful -- will check there before asking questions in the future. Thanks again!
– Greg
Dec 15 '18 at 22:20
Alright, nice. Please don't forget to accept the answer (by clicking on the outlined checkmark next to it)!
– Ingo Karkat
Dec 15 '18 at 22:25
add a comment |
Auto-formatting first sounds like a great feature, but it has many caveats, so I personally find it helpful only for very few editing tasks.
:help auto-format
offers good advice to make this workable. In particular:
- You need to properly define paragraphs. The simplest is paragraphs that are
separated by a blank line. When there is no separating blank line, consider
using the 'w' flag and adding a space at the end of each line in the
paragraphs except the last one.
So, :setlocal formatoptions+=w
and then it'll work as you expect. (But each line inside a paragraph will end with a trailing space!)
Thank you very much!! Tried this and it worked great. The auto-format documentation was also very helpful -- will check there before asking questions in the future. Thanks again!
– Greg
Dec 15 '18 at 22:20
Alright, nice. Please don't forget to accept the answer (by clicking on the outlined checkmark next to it)!
– Ingo Karkat
Dec 15 '18 at 22:25
add a comment |
Auto-formatting first sounds like a great feature, but it has many caveats, so I personally find it helpful only for very few editing tasks.
:help auto-format
offers good advice to make this workable. In particular:
- You need to properly define paragraphs. The simplest is paragraphs that are
separated by a blank line. When there is no separating blank line, consider
using the 'w' flag and adding a space at the end of each line in the
paragraphs except the last one.
So, :setlocal formatoptions+=w
and then it'll work as you expect. (But each line inside a paragraph will end with a trailing space!)
Auto-formatting first sounds like a great feature, but it has many caveats, so I personally find it helpful only for very few editing tasks.
:help auto-format
offers good advice to make this workable. In particular:
- You need to properly define paragraphs. The simplest is paragraphs that are
separated by a blank line. When there is no separating blank line, consider
using the 'w' flag and adding a space at the end of each line in the
paragraphs except the last one.
So, :setlocal formatoptions+=w
and then it'll work as you expect. (But each line inside a paragraph will end with a trailing space!)
answered Dec 13 '18 at 9:32
Ingo KarkatIngo Karkat
17.3k22343
17.3k22343
Thank you very much!! Tried this and it worked great. The auto-format documentation was also very helpful -- will check there before asking questions in the future. Thanks again!
– Greg
Dec 15 '18 at 22:20
Alright, nice. Please don't forget to accept the answer (by clicking on the outlined checkmark next to it)!
– Ingo Karkat
Dec 15 '18 at 22:25
add a comment |
Thank you very much!! Tried this and it worked great. The auto-format documentation was also very helpful -- will check there before asking questions in the future. Thanks again!
– Greg
Dec 15 '18 at 22:20
Alright, nice. Please don't forget to accept the answer (by clicking on the outlined checkmark next to it)!
– Ingo Karkat
Dec 15 '18 at 22:25
Thank you very much!! Tried this and it worked great. The auto-format documentation was also very helpful -- will check there before asking questions in the future. Thanks again!
– Greg
Dec 15 '18 at 22:20
Thank you very much!! Tried this and it worked great. The auto-format documentation was also very helpful -- will check there before asking questions in the future. Thanks again!
– Greg
Dec 15 '18 at 22:20
Alright, nice. Please don't forget to accept the answer (by clicking on the outlined checkmark next to it)!
– Ingo Karkat
Dec 15 '18 at 22:25
Alright, nice. Please don't forget to accept the answer (by clicking on the outlined checkmark next to it)!
– Ingo Karkat
Dec 15 '18 at 22:25
add a comment |
Thanks for contributing an answer to Super User!
- 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%2fsuperuser.com%2fquestions%2f1383169%2fhard-line-wrapping-in-vim-without-joining-in-insert-mode%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