tjr
tjr

Reputation: 155

How to get a custom sentence format in VIM?

I use vim to write a lot of text (mostly for research papers), and I recently start to format paragraphs and sentences like this:

Lorem ipsum dolor sit amet, consectetur adipiscing 
   elit sed diam et arcu scelerisque rutrum eget 
   vitae sed diam et arcu scelerisque rutrum eget 
   vitae sed diam et arcu scelerisque rutrum eget 
   vitae. 
Aenean euismod tristique sollicitudin. 
Vestibulum sed diam et arcu scelerisque rutrum eget 
   vitae sapien. 
Quisque dui ligula, semper eget iaculis at, eleifend 
   at ligula. 
Sed vestibulum tellus ac libero iaculis sit amet commodo
   sapien pellentesque. 
Cras quis dignissim neque.
Donec neque mauris, dictum tempus tincidunt in, 
   pellentesque sit amet dui. 

I hope you can guess the pattern.

Now I do this mostly manual what is some kind of akward, especially if you add text in the middle of the sentence. My question would be, how can i do this automagically?

I know that I can use "gq100" to force a linebreak on the next 100 lines, but this does not do exactly what I want. It would be great if this is not really a hard linebreak but only a virtual one, which means when I put the cursor in the line starting with "Lorem ipsum" I can copy and past the whole sentence with y and p as if there wouldn't be any linebreak at all.

Does someone have an idea on this one?

Cheers, T

Upvotes: 2

Views: 217

Answers (2)

moritz
moritz

Reputation: 5224

I guess this is what you are looking for, the breakindent patch for vim:

http://sqizit.bartletts.id.au/2011/01/31/vim-and-breakindent/

Upvotes: 2

kev
kev

Reputation: 161834

Do you mean: If a line starts with 3 spaces, it belong to previous sentence?

You can do this:

:set textwidth=0
:set wrap
:set showbreak=\ \ \ 

Note: there's a space after every \.

Try to type a very lone line. It'll auto wrap. And the next line starts with 3 spaces.

Upvotes: 3

Related Questions