I am trying to set the textwidth option in a python file and I added the following line at the end of my .py file:

# vim: set textwidth=120


  • :set textwidth?,
  • :echo &l:textwidth and
  • :echo &textwidth they all return 78 instead of the expected 120.

What I am doing wrong?

  • 1
    that doesn't seem to be a valid modeline? Sep 13, 2023 at 11:32
  • I missed the final colon, as per the accepted answer :)
    – Barzi2001
    Sep 13, 2023 at 12:20

1 Answer 1


You are missing the trailing colon (:)

You have to do:

# vim: set textwidth=120:


# vim: textwidth=120

Remark: the set: variant has been introduced because the other variant will parse the entire line as a list of options , preventing the use of comments of the kind /* */ , where the set: variant will only consider the text between set and :. That is the reason why the : is important (see: Modelline magic)

More information with :help modeline

  • 1
    Well spotted. I totally missed that. However, I think the ':' is called a "colon", not "column". I'd edit the typo myself but with the little reputation I have, I would need to change at least 6 characters and wait for peer review... *sigh*
    – Friedrich
    Sep 13, 2023 at 11:43
  • 1
    Thanks. Some one did it for you :-) Sep 13, 2023 at 12:04
  • 1
    I seem to be completely useless today. Have an upvote, it's the least I can do.
    – Friedrich
    Sep 13, 2023 at 12:16

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.