1

I try to fold on Python functions, not on indent. Is there a build in method or Regex-rule I can use? (Solved further down)

This is my code so far:

set foldmethod=indent
nnoremap <space> za
vnoremap <space> zf

Two last lines is for open/closing with Space.

The top/black-version is what I try to accomplish. Overlapping terminal is my version (+styling) enter image description here (From Fast.ai - Lesson 3: Deep Learning 2018)

Complete with styling:

set foldmethod=indent
nnoremap <space> za
vnoremap <space> zf
syntax on
colorscheme desert

(How to change the global-config in Vim: 'cd ~' and 'vim .vimrc')


Solution from python-mode:

cd ~/.vim/pack/foo/start
git clone https://github.com/python-mode/python-mode.git
cd python-mode
git submodule update --init --recursive

And this line in ~/.vimrc to enable closing with space

nnoremap <space> za

Could be that you have to create all the folders in ~/.vim/pack/foo/start

My result: result

6
  • Regex can't parse everything. Commented Feb 5, 2018 at 14:33
  • 1
    If you can't find it here, you might want to ask on Vi and Vim Stack Exchange. Be sure to read their rules beforehand though. Commented Feb 5, 2018 at 14:36
  • user202729, do you have examples where it can't parse? Commented Feb 5, 2018 at 14:36
  • 1
    HTML. Commented Feb 5, 2018 at 14:37
  • user202729, HTML-parsing is a different problem than this example. I don't see how your example would limit parsing functions in Python, even if they include HTML. Commented Feb 5, 2018 at 14:46

1 Answer 1

2

The excellent python-mode plug-in folds on its own, more advanced expression, by default. It produces the results in your screenshot.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.