1

I am using a recorded macro to manually wrap an extremely long string in a python script, like this:

blah = ('blahblah ... blah blah')

to

blah = ('blahblah...'
        'blahblah...'
        ...
        'blahblah...')

the macro is 4f,a''^[i^M^[

This works fine, preserving my indentation right up to the point that the first line blah =... reaches the top of the page, then suddenly it starts dedenting to the first character of the line. How can I prevent this? i.e., how can I make vim recognize that the opening paren is above the top of the page?

EDIT: OK, it's not the top of the page, but 50 lines above, and my window (at present) is 52 lines.

  • I don't understand your macro. Specifically, the 4f, part; this jumps to the fourth comma, but your example string doesn't have any commas. You should probably create a Minimal, Complete, and Verifiable example. – Martin Tournoij Mar 2 '16 at 15:08
  • Give :set autoindent before trying macro. It works for me. – SibiCoder May 24 '16 at 12:24
  • Give :set autoindent before trying macro. It works for me. – SibiCoder May 24 '16 at 12:26

Your Answer

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

Browse other questions tagged or ask your own question.