Thursday, December 15, 2016

Re: How to fold or hide the comment in vimrc file?

2016-12-16 5:41 GMT+03:00 Zhe Lee <imlegendlzz@gmail.com>:
> I want to fold or hide the comment in the vimrc file.
> I Google it and find mainly the 2 solution below but none of them worked.
>
>
> syn match comment "\v(^\s*\".*\n)+" fold
>
> set foldmethod=expr foldexpr=getline(v:lnum)=~'^\s*"'
>
>
> My Vimrc file is like this, when I enter the 2 commands above nothing happens.

First solution is incomplete (and probably will work only if you
disable syntax highlighting or modify syntax/vim.vim file, not sure),
second solution is incorrect: while it clearly was supposed to set
`&foldexpr` to `getline(v:lnum)=~'^\s*"'`, it really sets it to
`getline(v:lnum)=~'^s`: missing proper escaping results in `\s`
transformed into `s` (backslash needs to be escaped) and `"` starting
a comment (needs to be escaped too). In addition to this it is using
:set setting global values alongside with local while it should use
:setlocal to set only local values. Proper second variant is

let &l:foldexpr='getline(v:lnum)=~#'.string('^\s*"')
setlocal foldmethod=expr

First method lacks `foldmethod` setting.

>
> ```
> if g:atCompany
> " set tags+=D:/Ruchee/Files/code/self/ci/tags
> " set tags+=D:/Ruchee/Files/code/self/laravel/tags
> " set tags+=D:/Ruchee/Files/code/self/sf/tags
> else
> ```
>
> So how to hide the comments?
>
> -----------
> Another question plz, how to edit the code format in this edit box? It's terriable that I can't post code here.
>
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: