6

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, 'fileformat' and 'fileformats' options will not be used, the file is read and written like 'fileformat' was "unix" (a single <NL> separates lines). The second part ...


4

Maybe it sounds too simplistic, but why not %!fmt -9999


3

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 each paragraph. From the vim help about the global command: The global commands work by first scanning through the lines and marking each line where a match ...


3

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 the 1st capture group. \n is a newline. ([^\n]) is any character except a newline in the 2nd capture group. For each such match, replace it by the 1st ...


2

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 :normal! J). Because the line numbers change, the execution gets off a bit. Trying :vglobal with a smarter range One idea is to join from each non-blank line to ...


2

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 writing it by setting 'nofixeol': When writing a file and this option is on, <EOL> at the end of file will be restored if missing. Turn this option off if ...


2

As stated in your comment you have cindent and cinoptions set like: set cindent set cinoptions=N-s,g0,:0,(0 The options cindent should only be set for the file types you want to use it. It is set automatically for the C or CPP file types (assuming you have filetype indent on in your vimrc [or better: filetype plugin indent on]). Remove the line set ...


1

Select the lines you'd like to merge, enter an Ex command by typing a colon : in normal mode. Then type this command: s/$\n\s*//gc The entire command should look likewise: :'<,'>s/$\n\s*//gc This is actually a tweaked version of the @insidepower's command that replaces space-indentations as well as newline characters. Explanation: '<,'> ...


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