سؤال
هل هناك أي طريقة أو أدوات لطي الوظيفة في VIM ، مثل Visual Studio أو Eclipse؟
المحلول
Vim folding commands
---------------------------------
zf#j creates a fold from the cursor down # lines.
zf/ string creates a fold from the cursor to string .
zj moves the cursor to the next fold.
zk moves the cursor to the previous fold.
za toggle a fold at the cursor.
zo opens a fold at the cursor.
zO opens all folds at the cursor.
zc closes a fold under cursor.
zm increases the foldlevel by one.
zM closes all open folds.
zr decreases the foldlevel by one.
zR decreases the foldlevel to zero -- all folds will be open.
zd deletes the fold at the cursor.
zE deletes all folds.
[z move to start of open fold.
]z move to end of open fold.
المصدر: مستندات VIM.
نصائح أخرى
نعم. VIM لديه قدرات قابلة للطي استثنائية. لا أحب تعلم الكثير من عناصر التحكم ، أفضّل الأتمتة ، لذا فإن ما أستخدمه شخصيًا:
في بلدي .vimrc:
set foldmethod=indent
set foldlevel=1
set foldclose=all
يطوي هذا تلقائيًا الملفات التي تفتحها ، استنادًا إلى المسافة البادئة ، لكل شيء مسافة بادئة لأكثر من مستوى واحد. يجعل خيار FoldClose يعيد إعادة التعويم تلقائيًا بعد أن أتنقل من الطية.
ضوابط في الملف:
zo - opens folds
zc - closes fold
zm - increases auto fold depth
zr - reduces auto fold depth
وإذا شعرت بالضيق من الطيات ، فاستخدم
: set foldmethod=syntax
أو اضغط:
zR
لجعلهم جميعا يذهب بعيدا.
:set foldmethod=syntax
يجب طي جميع الوظائف والكتل الأخرى تلقائيًا ، إذا كان لديك ملف بناء الجملة لغتك.
VIM لديه دعم قابلة للطي ممتاز. هناك وثائق جيدة في نظام مساعدة VIM. فقط افتح Vim وافعل
:help usr_28.txt
بعد القراءة يمكنك القراءة أيضًا
:help folding
لمزيد من المعلومات.
نعم ، يرتبط بمفتاح "Z" ، على سبيل المثال ، يفتح Zo جميع الطيات. انظر ": مساعدة طي" في VIM لمزيد من المعلومات. يمكنك القيام بالطي وفقًا لقواعد بسيطة للغاية ، مثل المسافة البادئة ، أو وفقًا لبناء رمز.