2

Now, I am starting to use vim to edit "normal text", that is, other than programming code. Thus, a "line" is really a paragraph, and is usually "long". In the very end of the current GUI window, there are some more space, but if it is shorter than the next line, that is not shown and space is wasted. This effectively makes my window (already being split) quite small. In such case, how to make vim to split the next line, partly shown in the current window, leaving the rest displayed in next window, so that I see the latter half when I press ctrl-F?

Shown is a part of an essay I wrote in Chinese, with screenshot cropped at the lower half of the GUI window. As you can see, there is plenty of space between line 14 and the display of current filename, but line 15 is too long to be fit in such space.

I bet someone has asked this, but I don't know the name of this action, nor the keyword to find this information.

still plenty space

3

I found myself that it is :set display=lastline (where @@@ at the end of the last line indicates that line is unfinished), or :set display=truncate (where @@@, starting on a new line, displayed as the last line, indicates the same).

To quote :help 'display':

'display' 'dy'      string   (default "", set to "truncate" in
                            |defaults.vim|)
         global
         {not in Vi}
   Change the way text is displayed.  This is comma separated list of
   flags:
   lastline   When included, as much as possible of the last line
         in a window will be displayed.  "@@@" is put in the
         last columns of the last screen line to indicate the
         rest of the line is not displayed.
   truncate   Like "lastline", but "@@@" is displayed in the first
         column of the last screen line.  Overrules "lastline".
   uhex      Show unprintable characters hexadecimal as <xx>
         instead of using ^C and ~C.

   When neither "lastline" nor "truncate" is included, a last line that
   doesn't fit is replaced with "@" lines.

And I add this line shown and wrote a function, in order to toggle, using ctrl-d, between display=truncate (when I am writing prose and dealing with long lines) display= (when I am writing anything consisting of short lines, such as code). In .vimrc:

" Display, as much as possible, the next line not able to be fully shown
set display=
noremap <leader>d :call DisplayLastLine()<CR>

function! DisplayLastLine()
    if &display == ''
        let &display = 'truncate'
    else
        let &display = ''
    endif
endfunction

(Quicker than all of you this time, maybe because Americans are sleeping.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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