Quantcast

cpp and golang code fold problem

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

cpp and golang code fold problem

YZ Xie
Hi everyone,

my .vimrc was 
set foldmethod=syntax 
filetype plugin indent on   " Automatically detect file types.
syntax enable
 syntax on  
                 
but  it cannot fold code if file was named like *.cpp, but it can work well if file was name *.c or *.cc.  golang code failed too.

my vim was installed by source code from github,runtime director is /usr/share/vim/vim80. 

I have export VIMRUNTIMEDIR= /usr/share/vim/vim80 in /etc/profile and source it.

vim version was 8.0.439. 

how can I fix this problem?
thanks

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: cpp and golang code fold problem

YZ Xie
在 2017年3月29日星期三 UTC+8下午1:16:40,YZ Xie写道:

> Hi everyone,
>
>
> my .vimrc was 
> set foldmethod=syntax 
> filetype plugin indent on   " Automatically detect file types.
> syntax enable
>  syntax on  
>                  
> but  it cannot fold code if file was named like *.cpp, but it can work well if file was name *.c or *.cc.  golang code failed too.
>
>
> my vim was installed by source code from github,runtime director is /usr/share/vim/vim80. 
>
>
> I have export VIMRUNTIMEDIR= /usr/share/vim/vim80 in /etc/profile and source it.
>
>
> vim version was 8.0.439. 
>
>
> how can I fix this problem?
> thanks
when zc it show E490 no fold found, but rename source file from *.cpp to *.c or *.cc, it works well

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: cpp and golang code fold problem

Charles E Campbell Jr
In reply to this post by YZ Xie
YZ Xie wrote:

> Hi everyone,
>
> my .vimrc was
> set foldmethod=syntax
> filetype plugin indent on   " Automatically detect file types.
> syntax enable
>  syntax on  
>                  
> but  it cannot fold code if file was named like *.cpp, but it can work
> well if file was name *.c or *.cc.  golang code failed too.
>
> my vim was installed by source code from github,runtime director
> is /usr/share/vim/vim80.
>
> I have export VIMRUNTIMEDIR= /usr/share/vim/vim80 in /etc/profile and
> source it.
>
> vim version was 8.0.439.
>
Hello:

I just opened a *.cpp file with fdm=syntax, and it folded just fine
using your .vimrc (plus using set nocp).  Got any example source you
care to share that won't fold?

Also,syntax-enabled folding is something that the syntax highlighting
maintainers specify in ther syntax highlighting files.  I suggest you
make some examples that won't fold and send them along with an
explanation to the syntax files' maintainers.

Regards,
Chip Campbell

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: cpp and golang code fold problem

YZ Xie
Hi Campbell,
here is my code, 

test.h
================================================================
#include <iostream>
#include <string>
using namespace std;

class A {
public:
    A();

    string& print_name();




private:
    string& o_print();

    string name;
}
=================================================================


test.cpp
=================================================================
#include "test.h"
A::A()
{
    name = "xie";
}

string& A::print_name(){
    return do_print();
}

string& A::do_print() {
    cout << name << endl;
    name = "yang";
    return name;
}

int main()
{
    A a;
    string str = a.print_name();
    cout << str.c_str() << endl;
}
===================================================================



when rename test.cpp to test.cc, it works well, here is two screenshots
内嵌图片 1


内嵌图片 2


Regards

Xie



2017-03-29 22:19 GMT+08:00 Charles E Campbell <[hidden email]>:
YZ Xie wrote:
> Hi everyone,
>
> my .vimrc was
> set foldmethod=syntax
> filetype plugin indent on   " Automatically detect file types.
> syntax enable
>  syntax on
>
> but  it cannot fold code if file was named like *.cpp, but it can work
> well if file was name *.c or *.cc.  golang code failed too.
>
> my vim was installed by source code from github,runtime director
> is /usr/share/vim/vim80.
>
> I have export VIMRUNTIMEDIR= /usr/share/vim/vim80 in /etc/profile and
> source it.
>
> vim version was 8.0.439.
>
Hello:

I just opened a *.cpp file with fdm=syntax, and it folded just fine
using your .vimrc (plus using set nocp).  Got any example source you
care to share that won't fold?

Also,syntax-enabled folding is something that the syntax highlighting
maintainers specify in ther syntax highlighting files.  I suggest you
make some examples that won't fold and send them along with an
explanation to the syntax files' maintainers.

Regards,
Chip Campbell

--
--
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 a topic in the Google Groups "vim_use" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_use/VAmHd6YAA2U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: cpp and golang code fold problem

Christian Brabandt
Hi YZ!

In both cases please check the output of `:verbose set fdm? fen?`

Best,
Christian

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: cpp and golang code fold problem

YZ Xie
Hi Christian,
thanks, you're right, fdm was different when file postfix was different, *.cc was syntax, *.cpp was manual, so I need to check my .vimrc. but I have set fdm to syntax, it's strange.
Best
YZ

2017-03-30 2:12 GMT+08:00 Christian Brabandt <[hidden email]>:
Hi YZ!

In both cases please check the output of `:verbose set fdm? fen?`

Best,
Christian

--
--
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 a topic in the Google Groups "vim_use" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_use/VAmHd6YAA2U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...