10 votes
Accepted

How do I configure vim to show a character when a line is too long to be displayed?

You should the this :set listchars+=precedes:<,extends:> Ref: :h wrap :h 'listchars'
nobe4's user avatar
  • 15.9k
10 votes
Accepted

Automatically breaking lines in comments?

I like this one augroup comment_textwidth autocmd! autocmd TextChanged,TextChangedI * :call AdjustTextWidth() augroup END function! AdjustTextWidth() let syn_element = synIDattr(synID(...
ryuichiro's user avatar
  • 1,181
9 votes

How to split a line into multiple lines efficiently?

The easiest way I've found to split lines in Vim is the normal mode command gq (type both letters in quick succession in normal or visual mode). In visual mode, it will split whatever is selected, in ...
vdicarlo's user avatar
  • 123
8 votes
Accepted

What is the significance of "Incomplete last line" when opening a file?

The Unix convention is that a line is a sequence of zero or more characters ending with a newline character. A text file is a sequence of such lines. This is just a convention, but adhering to that ...
garyjohn's user avatar
  • 6,284
8 votes
Accepted

What does breakat&vim mean?

It resets the breakat option to the Vim default: ^I!@*-+;:,./?. Where ^I stands for the tab character. You get the corresponding help paragraph with the :help :set-default command. :se[t] {option}&...
Vivian De Smedt's user avatar
7 votes

how to avoid vim breaking line beyond 80 characters in fortran files

'textwidth' is local to the buffer. I imagine Vim's default fortran plugin ($RUNTIME/ftplugin/fortran.vim) is setting 'textwidth'. To override this default add the following to ~/.vim/after/ftplugin/...
Peter Rincker's user avatar
7 votes

Why is a Line Feed converted into a Null character inside the search register and into a Carriage Return on the command line?

First, thank you for this very comprehensive and thoughtful post. After some testing, I have come to this conclusion: Control characters are displayed using the caret notation: ^M for <CR> (...
Géry Ogam's user avatar
7 votes
Accepted

Join all non-blank lines

Maybe it sounds too simplistic, but why not %!fmt -9999
Matt's user avatar
  • 20.4k
6 votes

Can I join lines with a comma (or another character)?

Just in case someone doesn't like typing Regex and memorizing more Plugin Ex Commands: Visual-block Append Visual-block Append is available in the Visual Block mode (<C-v>) and can do a block ...
Sunny Pun's user avatar
  • 472
6 votes
Accepted

Why does not Vim feed the correct set of newline characters?

There are two problems with your approach. First is using -b which turns on the 'binary' setting and the binary setting will ignore fileformat. See this snippet of :help 'binary': Also, '...
filbranden's user avatar
  • 28.4k
5 votes
Accepted

Line formatting (gq) does not correctly indent long list items

As far as I can tell (and from @Antony's comments), autoindent must be turned on for this to work. From the help pages: When autoindent is on, formatting (with the "gq" command or when you reach '...
s4y's user avatar
  • 316
5 votes
Accepted

Join multiple lines

I got the macro working: qqgg5j^V4j$xgg$p9jV4kd qq starts a macro called q gg sets the startingpoint to the first line of the file 5j goes down 5 lines (the start of the block below it) ^V4j$ goes ...
Mehdi Nellen's user avatar
5 votes
Accepted

Adding new characters cause splitting line into many lines

Try set textwidth=0 to not break up long lines. See :h tw. Note that if you set the textwidth to 0, then wrapmargin might take effect, see :h wm, so consider also using set wrapmargin=0.
PhilippFrank's user avatar
  • 1,225
5 votes

Join all non-blank lines

You were almost there: v/^$/norm vipJ For each matching line it selects the inner paragraph(without following newline) und joins.This works because, the command is only executed for the first line of ...
erba's user avatar
  • 51
4 votes

Still force new line at end, but show it too?

Like so many people, you seem to mix up "new line" and "newline". When editing a file where the last line doesn't end with a "newline" character, Vim will add that "newline" character on write unless ...
romainl's user avatar
  • 39.2k
4 votes

How to join lines without producing a space?

Create a macro and reuse it: qaJxq Now replay the macro, a by using @a wherever you want to join two lines with no space. @@ will repeat the previous macro. So you can just hold @ to join multiple ...
pellucide's user avatar
  • 141
4 votes
Accepted

Automatic wrapping to new line?

You could work with wrapmargin: set textwidth=0 set wrapmargin=1 set formatoptions+=t set formatoptions-=l The option wrapmargin defines the number of characters from the right window border where ...
Ralf's user avatar
  • 9,097
4 votes

Automatic wrapping to new line?

Set set textwidth=50 The 'textwidth' option can be used to automatically break a line before it gets too long. Set the 'textwidth' option to the desired maximum line length. If you then type ...
Maxim Kim's user avatar
  • 12.4k
4 votes

Join all non-blank lines

Normal substitution: %s/\([^\n]\)\n\([^\n]\)/\1 \2/ Substitution with magic mode, so as to drop escaping (): %s/\v([^\n])\n([^\n])/\1 \2/ Explanation: ([^\n]) is any character except a newline in ...
Quasímodo's user avatar
  • 2,416
3 votes
Accepted

How to make linebreak play along with conceal

No it is not possible. Wrapping occurs on the real characters on the line and not on the concealed characters. Note, that if this would be possible, this would cause kind of "wobbling" effect just by ...
Christian Brabandt's user avatar
3 votes

How to join lines without producing a space?

To always join with a single space : nmap J gJi <ESC>ciW <ESC> To join with no space at all (removes trailing+leading space) : nmap <C-J> gJi <ESC>diW
phil's user avatar
  • 31
3 votes

Join multiple lines

What you do is almost .. graphical, so I'd use the mouse! (of course you need :set mouse+=a) Select a block with the mouse, then Ctrl-v y to yank the selection in "control-block" mode (<- that's ...
VanLaser's user avatar
  • 9,620
3 votes

Join multiple lines

Another macro solution: First go to the beginning of the first paragraph (in your example with 10G) Then record macro: qqCtrl-Shit-V}$d5k$p0q Reuse the macro with @q The detail of the macro: Ctrl-...
statox's user avatar
  • 49.4k
3 votes

'endofline' option stays false after write operation

This behavior is intentional, to keep track of the original [noeol] status of the file when it was first read. Note that you can control whether to keep the original [noeol] status of a file when ...
filbranden's user avatar
  • 28.4k
3 votes

Join all non-blank lines

Why it doesn't work The reason your command works that way is that all the lines are marked for action first, then the join is run (aside: you can use :v/.../j to use the ex-command :join instead of :...
D. Ben Knoble's user avatar
  • 25.3k
3 votes
Accepted

How to insert a blank line above another line

You can make use of the :g command. There are probably already answers here on how to use :g and there is also this famous wiki article on the same topic In short, you simply run: :g/^Q/:-put ='' ...
Christian Brabandt's user avatar
3 votes

How to insert a blank line above another line

To follow up on @Christian Brabandt's answer, you can use the O key (see :help O) and do: :g/^Q/norm O norm allows to run a key command (O, dd, .....) in a command. :g can take a range also, so if ...
padawin's user avatar
  • 1,323
3 votes
Accepted

Function for recursive linebreak

A solution to review the paragraph you are in is: gqip Where: gq reformat them according to textwidth ip current paragraph If you want that to be made for all paragraph while they are edited a ...
Vivian De Smedt's user avatar
3 votes

how to delete every char except newline?

To remove all content of a line, you can use the :substitute command (see :help substitute) like this: :s/.*// It will substitute any character (.), repeated 0 or more times (*) with nothing. It will ...
Friedrich's user avatar
  • 1,209
2 votes

Can I join lines with a comma (or another character)?

To get around this limitation we can resolve this problem by splitting it for 2 separate simple problems: Add separator at the end of each line with one of command: :%s/$/,/ - :%s search whole file ...
S.R's user avatar
  • 121

Only top scored, non community-wiki answers of a minimum length are eligible