If I am using visual block mode to append to a block of text and number of characters exceeds 80, then the line snaps and text is not appended to rest of the block. I want to find a way such that line does not wrap around in visual mode,but when I am done with appending text, lines should automatically wrap after 80 characters.

1 Answer 1


Edit: I initially misunderstood this to be a problem with pasting; actually, you mean appending from visual mode. The following mapping should handle that, by temporarily resetting 'formatoptions' until you're done inserting:

:xnoremap A <Esc>:let save_fo = &fo<Bar>setl fo=<Bar>augroup TempInsert<Bar>augroup END<Bar>autocmd! TempInsert InsertLeave * let &fo = save_fo<Bar>autocmd! TempInsert<CR>gvA

I only see this effect with auto-formatting, i.e. :set formatoptions+=a.

If you don't want this when pasting, you could override the command, or provide a special alternative, like this:

:nnoremap <Leader>p :let save_fo = &fo<Bar>setl fo-=a<Bar>execute 'normal! "' . v:register . 'p'<Bar>let &fo = save_fo<CR>
  • I checked my formatoptions. It is set as 'tcroql'. Sorry if my question was not clear enough. I have no issues with auto-formatting. I would just like it to be "paused" when I am using visual mode, and resume after I exit it.
    – vimKoans44
    Commented Apr 24, 2015 at 4:02
  • Interesting, I don't see wrapping under such circumstances. Does my solution work when you do :setl fo-=c fo-=t instead of :setl fo-=a? You could also :set paste ... :set nopaste instead. Commented Apr 24, 2015 at 7:25
  • I think that what he is doing is pressing A in a visual block. I see the same behavior on my side. It should be possible to remap A in such conditions to save and reset tw, as you did with fo.
    – Vitor
    Commented Apr 24, 2015 at 18:09
  • @Vitor: Thanks, I think I really misunderstood. Yes, such remap is possible, if somewhat more complex. I've added that. Commented Apr 24, 2015 at 18:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.