@@ -352,8 +352,26 @@ fn set_line_ending(
352 arg if arg.starts_with("nel") => Nel,
352 arg if arg.starts_with("nel") => Nel,
353 _ => bail!("invalid line ending"),
353 _ => bail!("invalid line ending"),
355+ let (view, doc) = current!(cx.editor);
356+ doc.line_ending = line_ending;
359+ let transaction = Transaction::change(
361+ doc.text().lines().filter_map(|line| {
362+ pos += line.len_chars();
363+ match helix_core::line_ending::get_line_ending(&line) {
364+ Some(ending) if ending != line_ending => {
365+ let start = pos - ending.len_chars();
367+ Some((start, end, Some(line_ending.as_str().into())))
373+ doc.apply(&transaction, view.id);
356− doc_mut!(cx.editor).line_ending = line_ending;
@@ -1193,6 +1211,9 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
1193 TypableCommand {
1211 TypableCommand {
1194 name: "line-ending",
1212 name: "line-ending",
1195 aliases: &[],
1213 aliases: &[],
1214+ #[cfg(not(feature = "unicode-lines"))]
1215+ doc: "Set the document's default line ending. Options: crlf, lf.",
1216+ #[cfg(feature = "unicode-lines")]
1196 doc: "Set the document's default line ending. Options: crlf, lf, cr, ff, nel.",
1217 doc: "Set the document's default line ending. Options: crlf, lf, cr, ff, nel.",
1197 fun: set_line_ending,
1218 fun: set_line_ending,
1198 completer: None,
1219 completer: None,