0

I am using vim, by default I have not set the linebreak option in vim.So the following code:

aug =ImageDataGenerator(width_shift_range=0.1,height_shift_range=0.1,horizontal_flip=True,fill_mode="nearest")

is very long to fit in a single line in a window. So what I do is manually move and place the curser and then press enter resulting in:

aug = ImageDataGenerator(width_shift_range=0.1,
        height_shift_range=0.1, horizontal_flip=True,fill_mode="nearest") 

which is more readable for me. Now when I set the linebreak option, I get

aug = ImageDataGenerator(width_shift_range=0.1,
height_shift_range=0.1, horizontal_flip=True,fill_mode="nearest")

The code runs but is not comfortable to read, I would like to know is there any option in vim which automatically indents once the set linebreak option works.(i.e display the code like the 2nd one with proper indentation at the beginning of the second line).

1 Answer 1

1

The options are called :h 'breakindent' and :h 'breakindentopt'. For example

let [&l:bri, &l:briopt] = [v:true, 'shift:'..shiftwidth()]

Note that all "linebreak"-related spaces are purely virtual. They are never written into a file.

10
  • Thank you for the answer, but how should I use it, I have used :set breakindent but the line that follows is not intended. Where should I type the command you have given?
    – Hrushi
    Commented May 29, 2020 at 8:05
  • @Hrushi Shift value defaults to 0. For this reason you must set it with breakindentopt to see anything.
    – Matt
    Commented May 29, 2020 at 8:08
  • 1
    @Hrushi (1) Surely, it doesn't, as bri is boolean (2) And how did you do it with linebreak? Usually local options are overridden from after/ftplugin. There are at least several questions on this site with detailed explanations.
    – Matt
    Commented May 29, 2020 at 8:37
  • 1
    set breakindentopt=shift:8 did the work, it was very silly of me not checking this site for its correct usage, anyways thank you
    – Hrushi
    Commented May 29, 2020 at 9:37
  • 1
    How about checking the help for the options? Commented May 29, 2020 at 9:40

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.