I am the author of the plugin
I've spent quite a lot of time building & improving this, especially with
community feedback and it caters exactly to this use case.
A short quickstart: You enter 'table mode' with the :TableModeEnable command,
you can then simply type:
| MOVIE | QUOTE|
| Blade Runner | Like tears in the rain |
| Monty ...
You can use the gq or gw operators combined with a motion command. By default, formatting of applicable text is done by Vim and to the best of my knowledge it does not justify the lines (you will get ragged right margins). Alternatively, an external program (e.g. the fmt command on Linux) can be used to do the formatting by specifying it with the formatprg ...
There is a great VimCast on this topic.
Basically, you need to install par:
$ brew install par
$ sudo apt-get install par
And then, since you want columns to be wrapped in 80 columns:
:set formatprg=par\ -w80
Now you can use the gq operator, like in other answers (e.g. gqip), and it will use ...
You can use:
From :help 'display':
lastline When included, as much as possible of the last line
in a window will be displayed. When not included, a
last line that doesn't fit is replaced with "@" lines.
Autocommands to the rescue!
Put these lines in your vimrc:
autocmd FileType qf setlocal wrap
There's also this slightly cleaner method:
and put this line in it:
The first method adds yet another autocommand to the possibly large pile of autocommands already ...
You can indeed use an autocommand:
autocmd FileType qf setlocal wrap
This will affect the quickfix window, too, but I presume that would be desirable.
You can find a sort of oblique reference to this in the documentation by opening :help location-list and then searching for filetype.
Even better, use Vim's after ...
In the past I had similar problem with function signatures. Here is solution adapted to your problem. Add to .vimrc:
au CursorMovedI *.md call ModifyTextWidth() " Use only within *.md files
if getline(".")=~'^.*\[.*\](.*)$' " If the line ends with Markdown link - set big value for textwidth
Since you don't have wrapping for comments enabled, the workaround in this Stack Overflow post can be used:
This adds # as a comment marker (allowing nesting, so that ##, ###, etc. also count).
I'd suggest leaving a space after # and using nb:# - some Markdown parsers require a space after #. The CommonMark spec also supports ...
Try turning off automatic formatting:
If this works, you're going to want to try to track down how it's having an effect. There are two possibilities. Either you have 'wrapmargin' set (which causes Vim to insert newlines when you get within a certain distance of the edge of the window), or something is setting 'textwidth' after your ....
You can do this by setting textwidth, and removing t from formatoptions.
You also need to have the q option enabled in your formatoptions to use gq. It seems to always be on for me, but you might want to add a set formatoptions+=q to be on the safe side.
Shouldn't be a problem with your current usecase, but the c ...
If you can use sed and column, a command-line solution that comes close would be:
!sed 's/[- ]*\([+|]\)/'$'\x01''\1/g' | column -ts $'\x01' | sed '/^[-+ ]*$/s/ /-/g'
You could combine this with visual selection and '<,'> or with line numbers.
Uses sed and column. Vim is incidental.
The sed commands can probably be changed to vim :substitute ...
If you don't want to install any plugins and you want to edit tables keeping the alignment:
-- use the built in VREPLACE mode, activated by gR.
(Make sure you has vim latest version, and check if it's compiled with +vreplace feature, typing vim --version on the terminal)
(my statusline is set to show REPLACE for both REPLACE and VREPLACE modes)
If you ...
While nano's help call the ^J command "Justify" it actually doesn't justify the text, it reformat the text breaking the lines before the right margin of the screen (or at some configurable column, I guess).
You can do the same thing in VIM by setting the variable textwidth, from :help 'textwidth':
Maximum width of text that is being inserted. A longer ...
From one of my previous answers, you can get this to work if:
You have nb:> in your comments setting.
And you have q in your formatoptions setting.
After doing these, I get the expected wrapping:
> Tempus. Vivamus. Dis natoque vitae erat. Consectetuer adipiscing
> nullam nec gravida non, at posuere ...
You're looking for g0 and g$ which are the equivalent of 0 and $ for wrapped lines. See :h g0, :h g$ and even :h g^.
To quote the doc about g$:
When lines wrap ('wrap' on): To the last character of
the screen line and [count - 1] screen lines downward
|inclusive|. Differs from "$" when a line is wider
than the screen.
When lines don't wrap ('...
You can use the gj and gk commands to move the cursor to the character in the next or previous display lines, even when lines wrap.
See :help gj and :help gk for details.
If you would like to navigate those display lines using j and k, you can remap them in your .vimrc:
nnoremap j gj
nnoremap k gk
Beware that these remappings have side effects, for ...
One way to do it employs the ie (inside-environment) custom text object, available in a number of places: e.g. in the plugin vimtex, or with vim-textobj-latex (and there are others). With this functionality, then the rewrap command becomes:
(to maintain cursor position).
If you only want to reformat text from current text position (I see ...
As per Kenny Evitt's answer, you can find where textwidth is being set using verbose:
:verbose set tw?
Last set from c:\Program Files (x86)\Vim\vim74\vimrc_example.vim
If you are happy editing that file, do so.
If you would prefer not to edit whichever file (or cannot), then you can override it in your own .vimrc (or _vimrc) file.
From :help popt-option:
formfeed:y When a form feed character is encountered, continue
printing of the current line at the beginning of the
first line on a new page.
add the line below to your vimrc:
insert a form feed where you want your page break to occur with <C-l> in insert mode,
I think, you can use an BufEnter autocommand, that checks, whether the file is modifiable. Something like this should work (untested):
au BufEnter * if (!&modifiable || &ro) | setl wrap | endif
In my case, Vitor's comment suggested I run the following:
:verbose set tw?
Doing so gave me the following output:
Last set from C:\Program Files (x86)\Vim\vim74\vimrc_example.vim
In vimrc_example.vim, I found the relevant lines:
" Only do this part when compiled with support for autocommands.
" For all ...
If you're willing to change the way you write your Markdown slightly, you could fix this simply by introducing an extra blank line between your headings and the following text:
# this is a h1
this is the text of the file i want
This is how I personally format my atx-style Markdown headers, anyway: I think it looks better and is easier to read.
Soft wrapping per line is not possible. All you can really do is manually wrap the line with gql and undo it after you're done looking.
It might not be the exact answer that you're looking for, but you can make horizontal scrolling more ergonomic.
nnoremap <left> 5zh
nnoremap <right> 5zl
xnoremap <left> 5zh
xnoremap <right> 5zl
I was thinking about this more. You can't wrap just the current line in the current window, but you can open the buffer in a new window and enable wrapping there without affecting your current window.
Use a new window
split | setlocal wrap
After you're done, close the window that has wrapping enabled.
Use a new tab
If your horizontal space is limited ...
You're looking for :h 'wrap':
This option changes how text is displayed. It doesn't change the text
in the buffer, see 'textwidth' for that.
When on, lines longer than the width of the window will wrap and
displaying continues on the next line. When off lines will not wrap
and only part of long lines will be displayed. When the cursor is
You were almost there:
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 ...
This is not possible without some serious hackery. In fact, I can't really think of a hack short of modifying the Vim source code.
I also doubt that you really want this. The definition of a "line" is 0 or more characters ended by a newline, if you change that definition, you change a lot in Vim. For example, what would you expect a command like :s/A/B/ to ...