vim hit “enter” on a specific letter

2019-03-02 05:37发布

问题:

I want to hit enter on the arrow symbol in a file. Basically after hitting enter the arrow key collapses to show more text. I have so many such arrow keys.

▾ $wp_filter = (array [365])
  \
   ▸ $wp_filter['pre_term_name'] = (array [2])

After completely collapse

▾ $wp_filter = (array [365])
  \
   ▾ $wp_filter['pre_term_name'] = (array [2])
    \
     ▾ $wp_filter['pre_term_name'][10] = (array [2])
      \
       ▾ $wp_filter['pre_term_name'][10]['sanitize_text_field'] = (array [2])
        \
         ⬦ $wp_filter['pre_term_name'][10]['sanitize_text_field']['function'] = (string [19]) `sanitize_text_field`

I am trying

:%s/▸/\r/g

It does not collapse the text and the text after arrow breaks to next line.

▾ $wp_filter = (array [365])
  \

 $wp_filter['pre_term_name'] = (array [2])

I also tries

:%s/▸/▸\r/g

It breaks the line after the arrow mark.

▾ $wp_filter = (array [365])
  \
   ▸
 $wp_filter['pre_term_name'] = (array [2])

回答1:

see http://vim.wikia.com/wiki/Folding or http://vimdoc.sourceforge.net/htmldoc/fold.html

particularly: za toggles one level of folding, zA toggles all levels. You need to be on the node for this to work.

To open all folds in the file: zR (and zM will close all of them) (of course here, no need to be on a node, as it acts on all of them)



标签: vim replace