How to join a paragraph in normal mode?

28 views
Skip to first unread message

Igor

unread,
Dec 14, 2019, 8:35:50 AM12/14/19
to vim_use
For example I have the following text (at end of each line there is carriage return character):
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.


I would like to join all 6 lines into one paragraph (so removing carriage return at the end of line).

I know I can use:
- command line mode: :1,6j
- visual mode: vapJ
- normal mode with count lines: 6J

But is there some normal mode logic for JOIN A PARAGRAPH like:
- delete a paragraph: dap
- yank a paragraph: yap
- upper case a paragraph: gUap
and so what is the same normal mode logic for "join a paragraph"? Obiously Jap is not working, because J is full command by itself.

Question: How to join a paragraph in normal mode logic?

I use Vim 8.2.0003 on Linux.

Johannes Degen

unread,
Dec 14, 2019, 9:45:13 AM12/14/19
to vim...@googlegroups.com
How about :nnoremap K V}J  ?

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/a34a7681-d6b6-4e8a-805c-a0c76f1f5f31%40googlegroups.com.


--
When in doubt become a philosopher.

Igor

unread,
Dec 14, 2019, 11:22:53 AM12/14/19
to vim_use
@Johannes, I also see no other better way then remapping.

To have the same logic with 'join' as other commands like
'delete', 'yang', 'go upper case' etc I should change my .vimrc to:

" join current line
nnoremap JJ J

" join also a paragraph
nnoremap Jap vapJ

" join inner paragraph
nnoremap Jip vipJ

" join also a sentence
nnoremap Jas vasJ

" join inner sentence
nnoremap Jis visJ

" join to the end of buffer
nnoremap JG vGJ

" join to the beginning of the buffer
nnoremap Jgg vggJ

Reply all
Reply to author
Forward
0 new messages