Thursday, April 28, 2011

How to have a carriage return without bringing about a linebreak in VIM ?

Is it possible to have a carriage return without bringing about a linebreak ? For instance I want to write the following sentences in 2 lines and not 4 (and I do not want to type spaces of course) :

  1. On a ship at sea: a tempestuous noise of thunder and lightning heard. Enter a Master and a Boatswain
  2. Master : Boatswain! Boatswain : Here, master: what cheer?

Thanks in advance for your help

Thierry

From stackoverflow
  • I think here is the answer to your question:

    http://stackoverflow.com/questions/759577/how-do-i-make-text-wrapping-match-current-indentation-level-in-vim

    ThG : I am sorry, I did not pay attention to the way my question was transcribed in Stack Overflow It should have been : Is it possible to have a carriage return without bringing about a linebreak ? For instance I want to write the following sentences in 2 lines and not 4 (and I do not want to type spaces of course) : 1. On a ship at sea: a tempestuous noise of thunder and lightning heard. Enter a Master and a Boatswain 2. Master : Boatswain! Boatswain : Here, master: what cheer? Sorry again, and thanks for your help Thierry
    ThG : Oops even worse...I have problems with carriage returns. In fact the question sums up to : may I have a theater dialog transcribed in 1 Vim line but with carriage returns to distinguish the protagonists (here the Master and the Boatswain). Needless to say I am a newbie
  • In a text file, the expected line-end character or character sequence is platform dependent. On Windows, the sequence "carriage return (CR, \r) + line feed (LF, \n)" is used, while Unix systems use newline only (LF \n). Macintoshes traditionally used \r only, but these days on OS X I see them dealing with just about any version. Text editors on any system are often able to support all three versions, and to convert between them.

    For VIM, see this article for tips how to convert/set line end character sequences.

    However, I'm not exactly sure what advantage the change would have for you: Whichever sequence or character you use, it is just the marker for the end of the line (so there should be one of these, at the end of the first line and you'd have a 2 line text file in any event). However, if your application expects a certain character, you can either change the application -- many programming languages support some form of "universal" newline -- or change the data.

  • Just in case this is what you're looking for:

    :set wrap
    :set linebreak
    

    The first tells vim to wrap long lines, and the second tells it to only break lines at word breaks, instead of in the middle of words when it reaches the window size.

0 comments:

Post a Comment