Loading ...
Sorry, an error occurred while loading the content.

Re: automatic code completion in vim

Expand Messages
  • Mikolaj Machowski
    ... I ve made some tests and on big tags files it can be slow. The fastest method is:: let alltags = system( grep -v .fname) let alltags = split(alltags,
    Message 1 of 27 , Jan 1, 2007
    • 0 Attachment
      Dnia pon sty 1 2007, napisałeś:
      > remove() doesn't accept regexps only indexes. To remove offending lines
      > use filter()::
      >
      > call filter(alltags, "v:val !~ fname")

      I've made some tests and on big tags files it can be slow. The fastest
      method is::

      let alltags = system('grep -v '.fname)
      let alltags = split(alltags, '\n') " you have to end with List

      m.
    • A.J.Mechelynck
      ... This won t work: you need a different variable name, see :help E706 . Best regards, Tony.
      Message 2 of 27 , Jan 1, 2007
      • 0 Attachment
        Mikolaj Machowski wrote:
        > Dnia pon sty 1 2007, napisałeś:
        >> remove() doesn't accept regexps only indexes. To remove offending lines
        >> use filter()::
        >>
        >> call filter(alltags, "v:val !~ fname")
        >
        > I've made some tests and on big tags files it can be slow. The fastest
        > method is::
        >
        > let alltags = system('grep -v '.fname)
        > let alltags = split(alltags, '\n') " you have to end with List
        >
        > m.
        >
        >

        This won't work: you need a different variable name, see ":help E706".

        Best regards,
        Tony.
      • Mikolaj Machowski
        ... Yeah, I forgot (not only about that). This is complete solution:: function! UpdateTags() call writefile(getline(1, $ ), .tmp.cc , b ) let tags =
        Message 3 of 27 , Jan 1, 2007
        • 0 Attachment
          On pon sty 1 2007, Mikolaj Machowski wrote:
          > This won't work: you need a different variable name, see ":help E706".

          Yeah, I forgot (not only about that).

          This is complete solution::

          function! UpdateTags()
          call writefile(getline(1, '$'), '.tmp.cc', 'b')
          let tags = system('ctags --c++-kinds=+p --fields=+iaS --extra=+q -f
          - .tmp.cc')
          " Note: whitespaces around expand are tab chars.
          let alltags = system('grep -v " '.expand('%').' " tags')
          let tagstable = split(alltags, '\n')
          call add(tagstable, tags)
          call writefile(tagstable, 'tags', 'b')
          redraw!
          return ';'
          endfunction
          inoremap <expr> ; UpdateTags()

          Note: this is untested in real life, it doesn't return any errors.

          In good conditions execution of whole function takes 0.46s on big tags
          file (KMail source, tags size over 4MB, 10000 lines). Delay noticeable
          on my computer Sempron 2200, 512M RAM, old HD 5400rpm. In worse conditions
          it was taking up to 0.75s::

          FUNCTION UpdateTags()
          Called 1 time
          Total time: 0.527128
          Self time: 0.401542

          count total (s) self (s)
          1 0.000551 call writefile(getline(1, '$'), '.tmp.cc', 'b')
          1 0.026373 0.000298 let tags = system('ctags --c++-kinds=+p
          --fields=+iaS --extra=+q -f - .tmp.cc')
          1 0.000091 let stags = split(tags, '\n')
          1 0.130731 0.031220 let alltags = system('grep -v " '.expand('%').' "
          tags')
          1 0.128909 let tagstable = split(alltags, '\n')
          1 0.000043 call extend(tagstable, stags)
          1 0.240341 call writefile(tagstable, 'tags', 'b')
          1 0.000033 return ';'

          FUNCTIONS SORTED ON TOTAL TIME
          count total (s) self (s) function
          1 0.527128 0.401542 UpdateTags()

          FUNCTIONS SORTED ON SELF TIME
          count total (s) self (s) function
          1 0.527128 0.401542 UpdateTags()

          Note however I've made one fatal mistake. ``ctags fname`` will point to
          tags in file .tmp.cc not our real current file! Filtering tags in Vim is
          possible and on small sample quite fast but still 0.5s is long. Maybe we
          should put that strain to the system::

          function! UpdateTags()
          call writefile(getline(1, '$'), '.tmp.cc', 'b')
          call system('grep -v " '.expand('%').' " tags > tags2 && mv -f tags2
          tags')
          let tags = system('ctags --c++-kinds=+p --fields=+iaS --extra=+q -f
          - .tmp.cc | sed "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >> tags')
          return ';'
          endfunction
          inoremap <expr> ; UpdateTags()

          And here we have the winner::

          FUNCTION UpdateTags()
          Called 1 time
          Total time: 0.145700
          Self time: 0.001068

          count total (s) self (s)
          1 0.000523 call writefile(getline(1, '$'), '.tmp.cc', 'b')
          1 0.096118 0.000195 call system('grep -v " '.expand('%').' " tags >
          tags2 && mv -f tags2 tags')
          1 0.049003 0.000294 call system('ctags --c++-kinds=+p --fields=+iaS
          --extra=+q -f - .tmp.cc | sed "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >>
          tags')
          1 0.000029 return ';'

          FUNCTIONS SORTED ON TOTAL TIME
          count total (s) self (s) function
          1 0.145700 0.001068 UpdateTags()

          FUNCTIONS SORTED ON SELF TIME
          count total (s) self (s) function
          1 0.145700 0.001068 UpdateTags()


          Below 0.15s (and even in worse conditions only up to 0.25s)! This is
          less then one keystroke of good touchtyper. This is for the price of
          portability but you can find grep/sed/mv for other systems so situation
          isn't hopeless.

          HTH

          m.
        • zhengda
          ... Thank you for your script. It doesn t work so fast in my computer. There is another problem when I use omnicppcomplete plugin. I don t know if it is its
          Message 4 of 27 , Jan 2, 2007
          • 0 Attachment
            Mikolaj Machowski wrote:
            > On pon sty 1 2007, Mikolaj Machowski wrote:
            >
            >> This won't work: you need a different variable name, see ":help E706".
            >>
            >
            > Yeah, I forgot (not only about that).
            >
            > This is complete solution::
            >
            > function! UpdateTags()
            > call writefile(getline(1, '$'), '.tmp.cc', 'b')
            > let tags = system('ctags --c++-kinds=+p --fields=+iaS --extra=+q -f
            > - .tmp.cc')
            > " Note: whitespaces around expand are tab chars.
            > let alltags = system('grep -v " '.expand('%').' " tags')
            > let tagstable = split(alltags, '\n')
            > call add(tagstable, tags)
            > call writefile(tagstable, 'tags', 'b')
            > redraw!
            > return ';'
            > endfunction
            > inoremap <expr> ; UpdateTags()
            >
            > Note: this is untested in real life, it doesn't return any errors.
            >
            > In good conditions execution of whole function takes 0.46s on big tags
            > file (KMail source, tags size over 4MB, 10000 lines). Delay noticeable
            > on my computer Sempron 2200, 512M RAM, old HD 5400rpm. In worse conditions
            > it was taking up to 0.75s::
            >
            > FUNCTION UpdateTags()
            > Called 1 time
            > Total time: 0.527128
            > Self time: 0.401542
            >
            > count total (s) self (s)
            > 1 0.000551 call writefile(getline(1, '$'), '.tmp.cc', 'b')
            > 1 0.026373 0.000298 let tags = system('ctags --c++-kinds=+p
            > --fields=+iaS --extra=+q -f - .tmp.cc')
            > 1 0.000091 let stags = split(tags, '\n')
            > 1 0.130731 0.031220 let alltags = system('grep -v " '.expand('%').' "
            > tags')
            > 1 0.128909 let tagstable = split(alltags, '\n')
            > 1 0.000043 call extend(tagstable, stags)
            > 1 0.240341 call writefile(tagstable, 'tags', 'b')
            > 1 0.000033 return ';'
            >
            > FUNCTIONS SORTED ON TOTAL TIME
            > count total (s) self (s) function
            > 1 0.527128 0.401542 UpdateTags()
            >
            > FUNCTIONS SORTED ON SELF TIME
            > count total (s) self (s) function
            > 1 0.527128 0.401542 UpdateTags()
            >
            > Note however I've made one fatal mistake. ``ctags fname`` will point to
            > tags in file .tmp.cc not our real current file! Filtering tags in Vim is
            > possible and on small sample quite fast but still 0.5s is long. Maybe we
            > should put that strain to the system::
            >
            > function! UpdateTags()
            > call writefile(getline(1, '$'), '.tmp.cc', 'b')
            > call system('grep -v " '.expand('%').' " tags > tags2 && mv -f tags2
            > tags')
            > let tags = system('ctags --c++-kinds=+p --fields=+iaS --extra=+q -f
            > - .tmp.cc | sed "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >> tags')
            > return ';'
            > endfunction
            > inoremap <expr> ; UpdateTags()
            >
            > And here we have the winner::
            >
            > FUNCTION UpdateTags()
            > Called 1 time
            > Total time: 0.145700
            > Self time: 0.001068
            >
            > count total (s) self (s)
            > 1 0.000523 call writefile(getline(1, '$'), '.tmp.cc', 'b')
            > 1 0.096118 0.000195 call system('grep -v " '.expand('%').' " tags >
            > tags2 && mv -f tags2 tags')
            > 1 0.049003 0.000294 call system('ctags --c++-kinds=+p --fields=+iaS
            > --extra=+q -f - .tmp.cc | sed "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >>
            > tags')
            > 1 0.000029 return ';'
            >
            > FUNCTIONS SORTED ON TOTAL TIME
            > count total (s) self (s) function
            > 1 0.145700 0.001068 UpdateTags()
            >
            > FUNCTIONS SORTED ON SELF TIME
            > count total (s) self (s) function
            > 1 0.145700 0.001068 UpdateTags()
            >
            >
            > Below 0.15s (and even in worse conditions only up to 0.25s)! This is
            > less then one keystroke of good touchtyper. This is for the price of
            > portability but you can find grep/sed/mv for other systems so situation
            > isn't hopeless.
            >
            > HTH
            >
            > m.
            >
            >
            >
            Thank you for your script. It doesn't work so fast in my computer.
            There is another problem when I use omnicppcomplete plugin.
            I don't know if it is its bug.
            For example, there are two files:
            --------tmp1.h--------------------
            class tmp1{
            public:
            void print1(){}
            };
            --------hello.cc-----------------
            #include "tmp1.h"

            class hello{
            public:
            void print(){}
            static void hello(){}
            static int h;
            };

            int main(){
            hello h;
            hello::hello();
            h.
            hello::<C-x><C-o> <--------- the popup menu only appear here
            tmp1 t1;
            t1.
            }

            I'm sure tags has been created correctly. The popup menu sometimes
            appears, sometimes doesn't when I type '.' or '->'.
            I tried many times, but still didn't find the rule: when it appears,
            when it doesn't.
            Does anyone meet the similar program? Or has some ideas?

            Zheng Da
          • Vissale NEANG
            Hello, I am the maintainer of the script and I can reproduce the problem: 1 int main(){ 2 hello h; 3 hello::hello(); 4 h. 5 hello::
            Message 5 of 27 , Jan 3, 2007
            • 0 Attachment
              Hello,

              I am the maintainer of the script and I can reproduce the problem:

              1 int main(){
              2 hello h;
              3 hello::hello();
              4 h.
              5 hello::<C-x><C-o> <--------- the popup menu only appear here
              6 tmp1 t1;
              7 t1.
              8 }

              At line 4, the popup menu doesn't appear because of the brace at line
              1. Internally the script use the vim function "searchdecl" (same
              behaviour as the command "gd") to search the declaration line of your
              object "h". But "gd" works properly only if your brace starts a new
              line because it uses internally the command "[[" (:help gd and :help
              [[). So if you want to see the popup menu at line 4 you have to write
              your code like this :

              1 int main()
              2 { // This brace must starts the line
              3 hello h;
              4 hello::hello();
              5 h. // The popup menu should appear here
              6 hello::
              7 tmp1 t1;
              8 t1.
              9 }

              At line 8, the popup menu doesn't appear because, after the command
              "gd", the script tokenizes the source code from line 5 to 7 and the
              resulting code in our case is :

              h.hello::tmp1 t1;

              so the script found that the type of the object "t1" is
              "h.hello::tmp1", this is not correct.
              If you want to see the popup menu you have to, at least, terminate the
              instruction at line 6 with ";"

              1 int main()
              2 { // This brace must starts the line
              3 hello h;
              4 hello::hello();
              5 h.print(); // The popup menu should appear here
              6 hello::hello(); // you have to terminate properly your
              // instruction with ";" before the next declaration
              7 tmp1 t1;
              8 t1. // the popup menu should appear here
              9 }

              If you have other questions, I am there :)

              Best regards,

              Vissale

              2007/1/2, zhengda <zhengda1936@...>:
              > Mikolaj Machowski wrote:
              > > On pon sty 1 2007, Mikolaj Machowski wrote:
              > >
              > >> This won't work: you need a different variable name, see ":help E706".
              > >>
              > >
              > > Yeah, I forgot (not only about that).
              > >
              > > This is complete solution::
              > >
              > > function! UpdateTags()
              > > call writefile(getline(1, '$'), '.tmp.cc', 'b')
              > > let tags = system('ctags --c++-kinds=+p --fields=+iaS --extra=+q -f
              > > - .tmp.cc')
              > > " Note: whitespaces around expand are tab chars.
              > > let alltags = system('grep -v " '.expand('%').' " tags')
              > > let tagstable = split(alltags, '\n')
              > > call add(tagstable, tags)
              > > call writefile(tagstable, 'tags', 'b')
              > > redraw!
              > > return ';'
              > > endfunction
              > > inoremap <expr> ; UpdateTags()
              > >
              > > Note: this is untested in real life, it doesn't return any errors.
              > >
              > > In good conditions execution of whole function takes 0.46s on big tags
              > > file (KMail source, tags size over 4MB, 10000 lines). Delay noticeable
              > > on my computer Sempron 2200, 512M RAM, old HD 5400rpm. In worse conditions
              > > it was taking up to 0.75s::
              > >
              > > FUNCTION UpdateTags()
              > > Called 1 time
              > > Total time: 0.527128
              > > Self time: 0.401542
              > >
              > > count total (s) self (s)
              > > 1 0.000551 call writefile(getline(1, '$'), '.tmp.cc', 'b')
              > > 1 0.026373 0.000298 let tags = system('ctags --c++-kinds=+p
              > > --fields=+iaS --extra=+q -f - .tmp.cc')
              > > 1 0.000091 let stags = split(tags, '\n')
              > > 1 0.130731 0.031220 let alltags = system('grep -v " '.expand('%').' "
              > > tags')
              > > 1 0.128909 let tagstable = split(alltags, '\n')
              > > 1 0.000043 call extend(tagstable, stags)
              > > 1 0.240341 call writefile(tagstable, 'tags', 'b')
              > > 1 0.000033 return ';'
              > >
              > > FUNCTIONS SORTED ON TOTAL TIME
              > > count total (s) self (s) function
              > > 1 0.527128 0.401542 UpdateTags()
              > >
              > > FUNCTIONS SORTED ON SELF TIME
              > > count total (s) self (s) function
              > > 1 0.527128 0.401542 UpdateTags()
              > >
              > > Note however I've made one fatal mistake. ``ctags fname`` will point to
              > > tags in file .tmp.cc not our real current file! Filtering tags in Vim is
              > > possible and on small sample quite fast but still 0.5s is long. Maybe we
              > > should put that strain to the system::
              > >
              > > function! UpdateTags()
              > > call writefile(getline(1, '$'), '.tmp.cc', 'b')
              > > call system('grep -v " '.expand('%').' " tags > tags2 && mv -f tags2
              > > tags')
              > > let tags = system('ctags --c++-kinds=+p --fields=+iaS --extra=+q -f
              > > - .tmp.cc | sed "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >> tags')
              > > return ';'
              > > endfunction
              > > inoremap <expr> ; UpdateTags()
              > >
              > > And here we have the winner::
              > >
              > > FUNCTION UpdateTags()
              > > Called 1 time
              > > Total time: 0.145700
              > > Self time: 0.001068
              > >
              > > count total (s) self (s)
              > > 1 0.000523 call writefile(getline(1, '$'), '.tmp.cc', 'b')
              > > 1 0.096118 0.000195 call system('grep -v " '.expand('%').' " tags >
              > > tags2 && mv -f tags2 tags')
              > > 1 0.049003 0.000294 call system('ctags --c++-kinds=+p --fields=+iaS
              > > --extra=+q -f - .tmp.cc | sed "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >>
              > > tags')
              > > 1 0.000029 return ';'
              > >
              > > FUNCTIONS SORTED ON TOTAL TIME
              > > count total (s) self (s) function
              > > 1 0.145700 0.001068 UpdateTags()
              > >
              > > FUNCTIONS SORTED ON SELF TIME
              > > count total (s) self (s) function
              > > 1 0.145700 0.001068 UpdateTags()
              > >
              > >
              > > Below 0.15s (and even in worse conditions only up to 0.25s)! This is
              > > less then one keystroke of good touchtyper. This is for the price of
              > > portability but you can find grep/sed/mv for other systems so situation
              > > isn't hopeless.
              > >
              > > HTH
              > >
              > > m.
              > >
              > >
              > >
              > Thank you for your script. It doesn't work so fast in my computer.
              > There is another problem when I use omnicppcomplete plugin.
              > I don't know if it is its bug.
              > For example, there are two files:
              > --------tmp1.h--------------------
              > class tmp1{
              > public:
              > void print1(){}
              > };
              > --------hello.cc-----------------
              > #include "tmp1.h"
              >
              > class hello{
              > public:
              > void print(){}
              > static void hello(){}
              > static int h;
              > };
              >
              > int main(){
              > hello h;
              > hello::hello();
              > h.
              > hello::<C-x><C-o> <--------- the popup menu only appear here
              > tmp1 t1;
              > t1.
              > }
              >
              > I'm sure tags has been created correctly. The popup menu sometimes
              > appears, sometimes doesn't when I type '.' or '->'.
              > I tried many times, but still didn't find the rule: when it appears,
              > when it doesn't.
              > Does anyone meet the similar program? Or has some ideas?
              >
              > Zheng Da
              >
            • Zheng Da
              ... Thank you for your reply. It does work in h. in my case, when I changed the code like int main() { hello h; hello::hello(); h. } But for class tmp1, it
              Message 6 of 27 , Jan 3, 2007
              • 0 Attachment
                On 1/3/07, Vissale NEANG <fromtonrouge@...> wrote:
                > Hello,
                >
                > I am the maintainer of the script and I can reproduce the problem:
                >
                > 1 int main(){
                > 2 hello h;
                > 3 hello::hello();
                > 4 h.
                > 5 hello::<C-x><C-o> <--------- the popup menu only appear here
                > 6 tmp1 t1;
                > 7 t1.
                > 8 }
                >
                > At line 4, the popup menu doesn't appear because of the brace at line
                > 1. Internally the script use the vim function "searchdecl" (same
                > behaviour as the command "gd") to search the declaration line of your
                > object "h". But "gd" works properly only if your brace starts a new
                > line because it uses internally the command "[[" (:help gd and :help
                > [[). So if you want to see the popup menu at line 4 you have to write
                > your code like this :
                >
                > 1 int main()
                > 2 { // This brace must starts the line
                > 3 hello h;
                > 4 hello::hello();
                > 5 h. // The popup menu should appear here
                > 6 hello::
                > 7 tmp1 t1;
                > 8 t1.
                > 9 }
                >
                > At line 8, the popup menu doesn't appear because, after the command
                > "gd", the script tokenizes the source code from line 5 to 7 and the
                > resulting code in our case is :
                >
                > h.hello::tmp1 t1;
                >
                > so the script found that the type of the object "t1" is
                > "h.hello::tmp1", this is not correct.
                > If you want to see the popup menu you have to, at least, terminate the
                > instruction at line 6 with ";"
                >
                > 1 int main()
                > 2 { // This brace must starts the line
                > 3 hello h;
                > 4 hello::hello();
                > 5 h.print(); // The popup menu should appear here
                > 6 hello::hello(); // you have to terminate properly your
                > // instruction with ";" before the next declaration
                > 7 tmp1 t1;
                > 8 t1. // the popup menu should appear here
                > 9 }
                >
                > If you have other questions, I am there :)
                >
                > Best regards,
                >
                > Vissale
                >
                > 2007/1/2, zhengda <zhengda1936@...>:
                > > Mikolaj Machowski wrote:
                > > > On pon sty 1 2007, Mikolaj Machowski wrote:
                > > >
                > > >> This won't work: you need a different variable name, see ":help E706".
                > > >>
                > > >
                > > > Yeah, I forgot (not only about that).
                > > >
                > > > This is complete solution::
                > > >
                > > > function! UpdateTags()
                > > > call writefile(getline(1, '$'), '.tmp.cc', 'b')
                > > > let tags = system('ctags --c++-kinds=+p --fields=+iaS --extra=+q -f
                > > > - .tmp.cc')
                > > > " Note: whitespaces around expand are tab chars.
                > > > let alltags = system('grep -v " '.expand('%').' " tags')
                > > > let tagstable = split(alltags, '\n')
                > > > call add(tagstable, tags)
                > > > call writefile(tagstable, 'tags', 'b')
                > > > redraw!
                > > > return ';'
                > > > endfunction
                > > > inoremap <expr> ; UpdateTags()
                > > >
                > > > Note: this is untested in real life, it doesn't return any errors.
                > > >
                > > > In good conditions execution of whole function takes 0.46s on big tags
                > > > file (KMail source, tags size over 4MB, 10000 lines). Delay noticeable
                > > > on my computer Sempron 2200, 512M RAM, old HD 5400rpm. In worse conditions
                > > > it was taking up to 0.75s::
                > > >
                > > > FUNCTION UpdateTags()
                > > > Called 1 time
                > > > Total time: 0.527128
                > > > Self time: 0.401542
                > > >
                > > > count total (s) self (s)
                > > > 1 0.000551 call writefile(getline(1, '$'), '.tmp.cc', 'b')
                > > > 1 0.026373 0.000298 let tags = system('ctags --c++-kinds=+p
                > > > --fields=+iaS --extra=+q -f - .tmp.cc')
                > > > 1 0.000091 let stags = split(tags, '\n')
                > > > 1 0.130731 0.031220 let alltags = system('grep -v " '.expand('%').' "
                > > > tags')
                > > > 1 0.128909 let tagstable = split(alltags, '\n')
                > > > 1 0.000043 call extend(tagstable, stags)
                > > > 1 0.240341 call writefile(tagstable, 'tags', 'b')
                > > > 1 0.000033 return ';'
                > > >
                > > > FUNCTIONS SORTED ON TOTAL TIME
                > > > count total (s) self (s) function
                > > > 1 0.527128 0.401542 UpdateTags()
                > > >
                > > > FUNCTIONS SORTED ON SELF TIME
                > > > count total (s) self (s) function
                > > > 1 0.527128 0.401542 UpdateTags()
                > > >
                > > > Note however I've made one fatal mistake. ``ctags fname`` will point to
                > > > tags in file .tmp.cc not our real current file! Filtering tags in Vim is
                > > > possible and on small sample quite fast but still 0.5s is long. Maybe we
                > > > should put that strain to the system::
                > > >
                > > > function! UpdateTags()
                > > > call writefile(getline(1, '$'), '.tmp.cc', 'b')
                > > > call system('grep -v " '.expand('%').' " tags > tags2 && mv -f tags2
                > > > tags')
                > > > let tags = system('ctags --c++-kinds=+p --fields=+iaS --extra=+q -f
                > > > - .tmp.cc | sed "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >> tags')
                > > > return ';'
                > > > endfunction
                > > > inoremap <expr> ; UpdateTags()
                > > >
                > > > And here we have the winner::
                > > >
                > > > FUNCTION UpdateTags()
                > > > Called 1 time
                > > > Total time: 0.145700
                > > > Self time: 0.001068
                > > >
                > > > count total (s) self (s)
                > > > 1 0.000523 call writefile(getline(1, '$'), '.tmp.cc', 'b')
                > > > 1 0.096118 0.000195 call system('grep -v " '.expand('%').' " tags >
                > > > tags2 && mv -f tags2 tags')
                > > > 1 0.049003 0.000294 call system('ctags --c++-kinds=+p --fields=+iaS
                > > > --extra=+q -f - .tmp.cc | sed "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >>
                > > > tags')
                > > > 1 0.000029 return ';'
                > > >
                > > > FUNCTIONS SORTED ON TOTAL TIME
                > > > count total (s) self (s) function
                > > > 1 0.145700 0.001068 UpdateTags()
                > > >
                > > > FUNCTIONS SORTED ON SELF TIME
                > > > count total (s) self (s) function
                > > > 1 0.145700 0.001068 UpdateTags()
                > > >
                > > >
                > > > Below 0.15s (and even in worse conditions only up to 0.25s)! This is
                > > > less then one keystroke of good touchtyper. This is for the price of
                > > > portability but you can find grep/sed/mv for other systems so situation
                > > > isn't hopeless.
                > > >
                > > > HTH
                > > >
                > > > m.
                > > >
                > > >
                > > >
                > > Thank you for your script. It doesn't work so fast in my computer.
                > > There is another problem when I use omnicppcomplete plugin.
                > > I don't know if it is its bug.
                > > For example, there are two files:
                > > --------tmp1.h--------------------
                > > class tmp1{
                > > public:
                > > void print1(){}
                > > };
                > > --------hello.cc-----------------
                > > #include "tmp1.h"
                > >
                > > class hello{
                > > public:
                > > void print(){}
                > > static void hello(){}
                > > static int h;
                > > };
                > >
                > > int main(){
                > > hello h;
                > > hello::hello();
                > > h.
                > > hello::<C-x><C-o> <--------- the popup menu only appear here
                > > tmp1 t1;
                > > t1.
                > > }
                > >
                > > I'm sure tags has been created correctly. The popup menu sometimes
                > > appears, sometimes doesn't when I type '.' or '->'.
                > > I tried many times, but still didn't find the rule: when it appears,
                > > when it doesn't.
                > > Does anyone meet the similar program? Or has some ideas?
                > >
                > > Zheng Da
                > >
                >

                Thank you for your reply.
                It does work in "h." in my case, when I changed the code like
                int main()
                {
                hello h;
                hello::hello();
                h.
                }
                But for class tmp1, it still doesn't work. For this code,
                ----------tmp1.h--------------
                class tmp1
                {
                public:
                void print1(){}
                };
                ----------hello.cc------------
                #include "tmp1.h"

                int main()
                {
                tmp1 t1;
                t1. <-----no popup menu appears
                }
                It seems it only works for the class in the same file.
                If the class is in the header file, it doesn't.

                --
                With regards
                Zheng Da
              • zhengda
                ... These are my tags file and code files print1 tmp1.h /^ void print1(){}$/; f class:tmp1 access:public signature:() tmp1 tmp1.h /^class tmp1$/; c
                Message 7 of 27 , Jan 3, 2007
                • 0 Attachment
                  Vissale NEANG wrote:
                  > What is you ctags command?
                  > Could you send me your tag file?
                  >
                  > Just for comparison I give you my tag file
                  >
                  > 2007/1/3, Zheng Da <zhengda1936@...>:
                  >> On 1/3/07, Vissale NEANG <fromtonrouge@...> wrote:
                  >> > Hello,
                  >> >
                  >> > I am the maintainer of the script and I can reproduce the problem:
                  >> >
                  >> > 1 int main(){
                  >> > 2 hello h;
                  >> > 3 hello::hello();
                  >> > 4 h.
                  >> > 5 hello::<C-x><C-o> <--------- the popup menu only appear here
                  >> > 6 tmp1 t1;
                  >> > 7 t1.
                  >> > 8 }
                  >> >
                  >> > At line 4, the popup menu doesn't appear because of the brace at line
                  >> > 1. Internally the script use the vim function "searchdecl" (same
                  >> > behaviour as the command "gd") to search the declaration line of your
                  >> > object "h". But "gd" works properly only if your brace starts a new
                  >> > line because it uses internally the command "[[" (:help gd and :help
                  >> > [[). So if you want to see the popup menu at line 4 you have to write
                  >> > your code like this :
                  >> >
                  >> > 1 int main()
                  >> > 2 { // This brace must starts the line
                  >> > 3 hello h;
                  >> > 4 hello::hello();
                  >> > 5 h. // The popup menu should appear here
                  >> > 6 hello::
                  >> > 7 tmp1 t1;
                  >> > 8 t1.
                  >> > 9 }
                  >> >
                  >> > At line 8, the popup menu doesn't appear because, after the command
                  >> > "gd", the script tokenizes the source code from line 5 to 7 and the
                  >> > resulting code in our case is :
                  >> >
                  >> > h.hello::tmp1 t1;
                  >> >
                  >> > so the script found that the type of the object "t1" is
                  >> > "h.hello::tmp1", this is not correct.
                  >> > If you want to see the popup menu you have to, at least, terminate the
                  >> > instruction at line 6 with ";"
                  >> >
                  >> > 1 int main()
                  >> > 2 { // This brace must starts the line
                  >> > 3 hello h;
                  >> > 4 hello::hello();
                  >> > 5 h.print(); // The popup menu should appear here
                  >> > 6 hello::hello(); // you have to terminate properly your
                  >> > // instruction with ";" before the next
                  >> declaration
                  >> > 7 tmp1 t1;
                  >> > 8 t1. // the popup menu should appear here
                  >> > 9 }
                  >> >
                  >> > If you have other questions, I am there :)
                  >> >
                  >> > Best regards,
                  >> >
                  >> > Vissale
                  >> >
                  >> > 2007/1/2, zhengda <zhengda1936@...>:
                  >> > > Mikolaj Machowski wrote:
                  >> > > > On pon sty 1 2007, Mikolaj Machowski wrote:
                  >> > > >
                  >> > > >> This won't work: you need a different variable name, see
                  >> ":help E706".
                  >> > > >>
                  >> > > >
                  >> > > > Yeah, I forgot (not only about that).
                  >> > > >
                  >> > > > This is complete solution::
                  >> > > >
                  >> > > > function! UpdateTags()
                  >> > > > call writefile(getline(1, '$'), '.tmp.cc', 'b')
                  >> > > > let tags = system('ctags --c++-kinds=+p --fields=+iaS
                  >> --extra=+q -f
                  >> > > > - .tmp.cc')
                  >> > > > " Note: whitespaces around expand are tab chars.
                  >> > > > let alltags = system('grep -v " '.expand('%').' "
                  >> tags')
                  >> > > > let tagstable = split(alltags, '\n')
                  >> > > > call add(tagstable, tags)
                  >> > > > call writefile(tagstable, 'tags', 'b')
                  >> > > > redraw!
                  >> > > > return ';'
                  >> > > > endfunction
                  >> > > > inoremap <expr> ; UpdateTags()
                  >> > > >
                  >> > > > Note: this is untested in real life, it doesn't return any errors.
                  >> > > >
                  >> > > > In good conditions execution of whole function takes 0.46s on
                  >> big tags
                  >> > > > file (KMail source, tags size over 4MB, 10000 lines). Delay
                  >> noticeable
                  >> > > > on my computer Sempron 2200, 512M RAM, old HD 5400rpm. In worse
                  >> conditions
                  >> > > > it was taking up to 0.75s::
                  >> > > >
                  >> > > > FUNCTION UpdateTags()
                  >> > > > Called 1 time
                  >> > > > Total time: 0.527128
                  >> > > > Self time: 0.401542
                  >> > > >
                  >> > > > count total (s) self (s)
                  >> > > > 1 0.000551 call writefile(getline(1,
                  >> '$'), '.tmp.cc', 'b')
                  >> > > > 1 0.026373 0.000298 let tags = system('ctags
                  >> --c++-kinds=+p
                  >> > > > --fields=+iaS --extra=+q -f - .tmp.cc')
                  >> > > > 1 0.000091 let stags = split(tags,
                  >> '\n')
                  >> > > > 1 0.130731 0.031220 let alltags =
                  >> system('grep -v " '.expand('%').' "
                  >> > > > tags')
                  >> > > > 1 0.128909 let tagstable =
                  >> split(alltags, '\n')
                  >> > > > 1 0.000043 call extend(tagstable,
                  >> stags)
                  >> > > > 1 0.240341 call writefile(tagstable,
                  >> 'tags', 'b')
                  >> > > > 1 0.000033 return ';'
                  >> > > >
                  >> > > > FUNCTIONS SORTED ON TOTAL TIME
                  >> > > > count total (s) self (s) function
                  >> > > > 1 0.527128 0.401542 UpdateTags()
                  >> > > >
                  >> > > > FUNCTIONS SORTED ON SELF TIME
                  >> > > > count total (s) self (s) function
                  >> > > > 1 0.527128 0.401542 UpdateTags()
                  >> > > >
                  >> > > > Note however I've made one fatal mistake. ``ctags fname`` will
                  >> point to
                  >> > > > tags in file .tmp.cc not our real current file! Filtering tags
                  >> in Vim is
                  >> > > > possible and on small sample quite fast but still 0.5s is long.
                  >> Maybe we
                  >> > > > should put that strain to the system::
                  >> > > >
                  >> > > > function! UpdateTags()
                  >> > > > call writefile(getline(1, '$'), '.tmp.cc', 'b')
                  >> > > > call system('grep -v " '.expand('%').' " tags >
                  >> tags2 && mv -f tags2
                  >> > > > tags')
                  >> > > > let tags = system('ctags --c++-kinds=+p --fields=+iaS
                  >> --extra=+q -f
                  >> > > > - .tmp.cc | sed "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >> tags')
                  >> > > > return ';'
                  >> > > > endfunction
                  >> > > > inoremap <expr> ; UpdateTags()
                  >> > > >
                  >> > > > And here we have the winner::
                  >> > > >
                  >> > > > FUNCTION UpdateTags()
                  >> > > > Called 1 time
                  >> > > > Total time: 0.145700
                  >> > > > Self time: 0.001068
                  >> > > >
                  >> > > > count total (s) self (s)
                  >> > > > 1 0.000523 call writefile(getline(1,
                  >> '$'), '.tmp.cc', 'b')
                  >> > > > 1 0.096118 0.000195 call system('grep -v "
                  >> '.expand('%').' " tags >
                  >> > > > tags2 && mv -f tags2 tags')
                  >> > > > 1 0.049003 0.000294 call system('ctags
                  >> --c++-kinds=+p --fields=+iaS
                  >> > > > --extra=+q -f - .tmp.cc | sed
                  >> "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >>
                  >> > > > tags')
                  >> > > > 1 0.000029 return ';'
                  >> > > >
                  >> > > > FUNCTIONS SORTED ON TOTAL TIME
                  >> > > > count total (s) self (s) function
                  >> > > > 1 0.145700 0.001068 UpdateTags()
                  >> > > >
                  >> > > > FUNCTIONS SORTED ON SELF TIME
                  >> > > > count total (s) self (s) function
                  >> > > > 1 0.145700 0.001068 UpdateTags()
                  >> > > >
                  >> > > >
                  >> > > > Below 0.15s (and even in worse conditions only up to 0.25s)!
                  >> This is
                  >> > > > less then one keystroke of good touchtyper. This is for the
                  >> price of
                  >> > > > portability but you can find grep/sed/mv for other systems so
                  >> situation
                  >> > > > isn't hopeless.
                  >> > > >
                  >> > > > HTH
                  >> > > >
                  >> > > > m.
                  >> > > >
                  >> > > >
                  >> > > >
                  >> > > Thank you for your script. It doesn't work so fast in my computer.
                  >> > > There is another problem when I use omnicppcomplete plugin.
                  >> > > I don't know if it is its bug.
                  >> > > For example, there are two files:
                  >> > > --------tmp1.h--------------------
                  >> > > class tmp1{
                  >> > > public:
                  >> > > void print1(){}
                  >> > > };
                  >> > > --------hello.cc-----------------
                  >> > > #include "tmp1.h"
                  >> > >
                  >> > > class hello{
                  >> > > public:
                  >> > > void print(){}
                  >> > > static void hello(){}
                  >> > > static int h;
                  >> > > };
                  >> > >
                  >> > > int main(){
                  >> > > hello h;
                  >> > > hello::hello();
                  >> > > h.
                  >> > > hello::<C-x><C-o> <--------- the popup menu only appear here
                  >> > > tmp1 t1;
                  >> > > t1.
                  >> > > }
                  >> > >
                  >> > > I'm sure tags has been created correctly. The popup menu sometimes
                  >> > > appears, sometimes doesn't when I type '.' or '->'.
                  >> > > I tried many times, but still didn't find the rule: when it appears,
                  >> > > when it doesn't.
                  >> > > Does anyone meet the similar program? Or has some ideas?
                  >> > >
                  >> > > Zheng Da
                  >> > >
                  >> >
                  >>
                  >> Thank you for your reply.
                  >> It does work in "h." in my case, when I changed the code like
                  >> int main()
                  >> {
                  >> hello h;
                  >> hello::hello();
                  >> h.
                  >> }
                  >> But for class tmp1, it still doesn't work. For this code,
                  >> ----------tmp1.h--------------
                  >> class tmp1
                  >> {
                  >> public:
                  >> void print1(){}
                  >> };
                  >> ----------hello.cc------------
                  >> #include "tmp1.h"
                  >>
                  >> int main()
                  >> {
                  >> tmp1 t1;
                  >> t1. <-----no popup menu appears
                  >> }
                  >> It seems it only works for the class in the same file.
                  >> If the class is in the header file, it doesn't.
                  >>
                  >> --
                  >> With regards
                  >> Zheng Da
                  >>
                  These are my tags file and code files
                • Vissale NEANG
                  It s because your tag file is not sorted correctly, the last tag main should be the first tag in the file. The script does a tag binary search and the tags
                  Message 8 of 27 , Jan 4, 2007
                  • 0 Attachment
                    It's because your tag file is not sorted correctly, the last tag
                    "main" should be the first tag in the file. The script does a tag
                    binary search and the tags file must be sorted to work properly (:help
                    tag-binary-search).

                    Best regards,

                    Vissale

                    2007/1/3, zhengda <zhengda1936@...>:
                    > Vissale NEANG wrote:
                    > > What is you ctags command?
                    > > Could you send me your tag file?
                    > >
                    > > Just for comparison I give you my tag file
                    > >
                    > > 2007/1/3, Zheng Da <zhengda1936@...>:
                    > >> On 1/3/07, Vissale NEANG <fromtonrouge@...> wrote:
                    > >> > Hello,
                    > >> >
                    > >> > I am the maintainer of the script and I can reproduce the problem:
                    > >> >
                    > >> > 1 int main(){
                    > >> > 2 hello h;
                    > >> > 3 hello::hello();
                    > >> > 4 h.
                    > >> > 5 hello::<C-x><C-o> <--------- the popup menu only appear here
                    > >> > 6 tmp1 t1;
                    > >> > 7 t1.
                    > >> > 8 }
                    > >> >
                    > >> > At line 4, the popup menu doesn't appear because of the brace at line
                    > >> > 1. Internally the script use the vim function "searchdecl" (same
                    > >> > behaviour as the command "gd") to search the declaration line of your
                    > >> > object "h". But "gd" works properly only if your brace starts a new
                    > >> > line because it uses internally the command "[[" (:help gd and :help
                    > >> > [[). So if you want to see the popup menu at line 4 you have to write
                    > >> > your code like this :
                    > >> >
                    > >> > 1 int main()
                    > >> > 2 { // This brace must starts the line
                    > >> > 3 hello h;
                    > >> > 4 hello::hello();
                    > >> > 5 h. // The popup menu should appear here
                    > >> > 6 hello::
                    > >> > 7 tmp1 t1;
                    > >> > 8 t1.
                    > >> > 9 }
                    > >> >
                    > >> > At line 8, the popup menu doesn't appear because, after the command
                    > >> > "gd", the script tokenizes the source code from line 5 to 7 and the
                    > >> > resulting code in our case is :
                    > >> >
                    > >> > h.hello::tmp1 t1;
                    > >> >
                    > >> > so the script found that the type of the object "t1" is
                    > >> > "h.hello::tmp1", this is not correct.
                    > >> > If you want to see the popup menu you have to, at least, terminate the
                    > >> > instruction at line 6 with ";"
                    > >> >
                    > >> > 1 int main()
                    > >> > 2 { // This brace must starts the line
                    > >> > 3 hello h;
                    > >> > 4 hello::hello();
                    > >> > 5 h.print(); // The popup menu should appear here
                    > >> > 6 hello::hello(); // you have to terminate properly your
                    > >> > // instruction with ";" before the next
                    > >> declaration
                    > >> > 7 tmp1 t1;
                    > >> > 8 t1. // the popup menu should appear here
                    > >> > 9 }
                    > >> >
                    > >> > If you have other questions, I am there :)
                    > >> >
                    > >> > Best regards,
                    > >> >
                    > >> > Vissale
                    > >> >
                    > >> > 2007/1/2, zhengda <zhengda1936@...>:
                    > >> > > Mikolaj Machowski wrote:
                    > >> > > > On pon sty 1 2007, Mikolaj Machowski wrote:
                    > >> > > >
                    > >> > > >> This won't work: you need a different variable name, see
                    > >> ":help E706".
                    > >> > > >>
                    > >> > > >
                    > >> > > > Yeah, I forgot (not only about that).
                    > >> > > >
                    > >> > > > This is complete solution::
                    > >> > > >
                    > >> > > > function! UpdateTags()
                    > >> > > > call writefile(getline(1, '$'), '.tmp.cc', 'b')
                    > >> > > > let tags = system('ctags --c++-kinds=+p --fields=+iaS
                    > >> --extra=+q -f
                    > >> > > > - .tmp.cc')
                    > >> > > > " Note: whitespaces around expand are tab chars.
                    > >> > > > let alltags = system('grep -v " '.expand('%').' "
                    > >> tags')
                    > >> > > > let tagstable = split(alltags, '\n')
                    > >> > > > call add(tagstable, tags)
                    > >> > > > call writefile(tagstable, 'tags', 'b')
                    > >> > > > redraw!
                    > >> > > > return ';'
                    > >> > > > endfunction
                    > >> > > > inoremap <expr> ; UpdateTags()
                    > >> > > >
                    > >> > > > Note: this is untested in real life, it doesn't return any errors.
                    > >> > > >
                    > >> > > > In good conditions execution of whole function takes 0.46s on
                    > >> big tags
                    > >> > > > file (KMail source, tags size over 4MB, 10000 lines). Delay
                    > >> noticeable
                    > >> > > > on my computer Sempron 2200, 512M RAM, old HD 5400rpm. In worse
                    > >> conditions
                    > >> > > > it was taking up to 0.75s::
                    > >> > > >
                    > >> > > > FUNCTION UpdateTags()
                    > >> > > > Called 1 time
                    > >> > > > Total time: 0.527128
                    > >> > > > Self time: 0.401542
                    > >> > > >
                    > >> > > > count total (s) self (s)
                    > >> > > > 1 0.000551 call writefile(getline(1,
                    > >> '$'), '.tmp.cc', 'b')
                    > >> > > > 1 0.026373 0.000298 let tags = system('ctags
                    > >> --c++-kinds=+p
                    > >> > > > --fields=+iaS --extra=+q -f - .tmp.cc')
                    > >> > > > 1 0.000091 let stags = split(tags,
                    > >> '\n')
                    > >> > > > 1 0.130731 0.031220 let alltags =
                    > >> system('grep -v " '.expand('%').' "
                    > >> > > > tags')
                    > >> > > > 1 0.128909 let tagstable =
                    > >> split(alltags, '\n')
                    > >> > > > 1 0.000043 call extend(tagstable,
                    > >> stags)
                    > >> > > > 1 0.240341 call writefile(tagstable,
                    > >> 'tags', 'b')
                    > >> > > > 1 0.000033 return ';'
                    > >> > > >
                    > >> > > > FUNCTIONS SORTED ON TOTAL TIME
                    > >> > > > count total (s) self (s) function
                    > >> > > > 1 0.527128 0.401542 UpdateTags()
                    > >> > > >
                    > >> > > > FUNCTIONS SORTED ON SELF TIME
                    > >> > > > count total (s) self (s) function
                    > >> > > > 1 0.527128 0.401542 UpdateTags()
                    > >> > > >
                    > >> > > > Note however I've made one fatal mistake. ``ctags fname`` will
                    > >> point to
                    > >> > > > tags in file .tmp.cc not our real current file! Filtering tags
                    > >> in Vim is
                    > >> > > > possible and on small sample quite fast but still 0.5s is long.
                    > >> Maybe we
                    > >> > > > should put that strain to the system::
                    > >> > > >
                    > >> > > > function! UpdateTags()
                    > >> > > > call writefile(getline(1, '$'), '.tmp.cc', 'b')
                    > >> > > > call system('grep -v " '.expand('%').' " tags >
                    > >> tags2 && mv -f tags2
                    > >> > > > tags')
                    > >> > > > let tags = system('ctags --c++-kinds=+p --fields=+iaS
                    > >> --extra=+q -f
                    > >> > > > - .tmp.cc | sed "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >> tags')
                    > >> > > > return ';'
                    > >> > > > endfunction
                    > >> > > > inoremap <expr> ; UpdateTags()
                    > >> > > >
                    > >> > > > And here we have the winner::
                    > >> > > >
                    > >> > > > FUNCTION UpdateTags()
                    > >> > > > Called 1 time
                    > >> > > > Total time: 0.145700
                    > >> > > > Self time: 0.001068
                    > >> > > >
                    > >> > > > count total (s) self (s)
                    > >> > > > 1 0.000523 call writefile(getline(1,
                    > >> '$'), '.tmp.cc', 'b')
                    > >> > > > 1 0.096118 0.000195 call system('grep -v "
                    > >> '.expand('%').' " tags >
                    > >> > > > tags2 && mv -f tags2 tags')
                    > >> > > > 1 0.049003 0.000294 call system('ctags
                    > >> --c++-kinds=+p --fields=+iaS
                    > >> > > > --extra=+q -f - .tmp.cc | sed
                    > >> "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >>
                    > >> > > > tags')
                    > >> > > > 1 0.000029 return ';'
                    > >> > > >
                    > >> > > > FUNCTIONS SORTED ON TOTAL TIME
                    > >> > > > count total (s) self (s) function
                    > >> > > > 1 0.145700 0.001068 UpdateTags()
                    > >> > > >
                    > >> > > > FUNCTIONS SORTED ON SELF TIME
                    > >> > > > count total (s) self (s) function
                    > >> > > > 1 0.145700 0.001068 UpdateTags()
                    > >> > > >
                    > >> > > >
                    > >> > > > Below 0.15s (and even in worse conditions only up to 0.25s)!
                    > >> This is
                    > >> > > > less then one keystroke of good touchtyper. This is for the
                    > >> price of
                    > >> > > > portability but you can find grep/sed/mv for other systems so
                    > >> situation
                    > >> > > > isn't hopeless.
                    > >> > > >
                    > >> > > > HTH
                    > >> > > >
                    > >> > > > m.
                    > >> > > >
                    > >> > > >
                    > >> > > >
                    > >> > > Thank you for your script. It doesn't work so fast in my computer.
                    > >> > > There is another problem when I use omnicppcomplete plugin.
                    > >> > > I don't know if it is its bug.
                    > >> > > For example, there are two files:
                    > >> > > --------tmp1.h--------------------
                    > >> > > class tmp1{
                    > >> > > public:
                    > >> > > void print1(){}
                    > >> > > };
                    > >> > > --------hello.cc-----------------
                    > >> > > #include "tmp1.h"
                    > >> > >
                    > >> > > class hello{
                    > >> > > public:
                    > >> > > void print(){}
                    > >> > > static void hello(){}
                    > >> > > static int h;
                    > >> > > };
                    > >> > >
                    > >> > > int main(){
                    > >> > > hello h;
                    > >> > > hello::hello();
                    > >> > > h.
                    > >> > > hello::<C-x><C-o> <--------- the popup menu only appear here
                    > >> > > tmp1 t1;
                    > >> > > t1.
                    > >> > > }
                    > >> > >
                    > >> > > I'm sure tags has been created correctly. The popup menu sometimes
                    > >> > > appears, sometimes doesn't when I type '.' or '->'.
                    > >> > > I tried many times, but still didn't find the rule: when it appears,
                    > >> > > when it doesn't.
                    > >> > > Does anyone meet the similar program? Or has some ideas?
                    > >> > >
                    > >> > > Zheng Da
                    > >> > >
                    > >> >
                    > >>
                    > >> Thank you for your reply.
                    > >> It does work in "h." in my case, when I changed the code like
                    > >> int main()
                    > >> {
                    > >> hello h;
                    > >> hello::hello();
                    > >> h.
                    > >> }
                    > >> But for class tmp1, it still doesn't work. For this code,
                    > >> ----------tmp1.h--------------
                    > >> class tmp1
                    > >> {
                    > >> public:
                    > >> void print1(){}
                    > >> };
                    > >> ----------hello.cc------------
                    > >> #include "tmp1.h"
                    > >>
                    > >> int main()
                    > >> {
                    > >> tmp1 t1;
                    > >> t1. <-----no popup menu appears
                    > >> }
                    > >> It seems it only works for the class in the same file.
                    > >> If the class is in the header file, it doesn't.
                    > >>
                    > >> --
                    > >> With regards
                    > >> Zheng Da
                    > >>
                    > These are my tags file and code files
                    >
                    >
                    > print1 tmp1.h /^ void print1(){}$/;" f class:tmp1 access:public signature:()
                    > tmp1 tmp1.h /^class tmp1$/;" c
                    > tmp1::print1 tmp1.h /^ void print1(){}$/;" f class:tmp1 access:public signature:()
                    > main test.cpp /^int main()$/;" f signature:()
                    >
                    >
                    >
                    >
                  • Vissale NEANG
                    You can use the vim sort command (:help sort) instead of gnu sort. Moreover it s portable.
                    Message 9 of 27 , Jan 4, 2007
                    • 0 Attachment
                      You can use the vim sort command (:help sort) instead of gnu sort.
                      Moreover it's portable.

                      2007/1/4, Zheng Da <zhengda1936@...>:
                      > On 1/4/07, Vissale NEANG <fromtonrouge@...> wrote:
                      > > It's because your tag file is not sorted correctly, the last tag
                      > > "main" should be the first tag in the file. The script does a tag
                      > > binary search and the tags file must be sorted to work properly (:help
                      > > tag-binary-search).
                      > >
                      > > Best regards,
                      > >
                      > > Vissale
                      > >
                      > > 2007/1/3, zhengda <zhengda1936@...>:
                      > > > Vissale NEANG wrote:
                      > > > > What is you ctags command?
                      > > > > Could you send me your tag file?
                      > > > >
                      > > > > Just for comparison I give you my tag file
                      > > > >
                      > > > > 2007/1/3, Zheng Da <zhengda1936@...>:
                      > > > >> On 1/3/07, Vissale NEANG <fromtonrouge@...> wrote:
                      > > > >> > Hello,
                      > > > >> >
                      > > > >> > I am the maintainer of the script and I can reproduce the problem:
                      > > > >> >
                      > > > >> > 1 int main(){
                      > > > >> > 2 hello h;
                      > > > >> > 3 hello::hello();
                      > > > >> > 4 h.
                      > > > >> > 5 hello::<C-x><C-o> <--------- the popup menu only appear here
                      > > > >> > 6 tmp1 t1;
                      > > > >> > 7 t1.
                      > > > >> > 8 }
                      > > > >> >
                      > > > >> > At line 4, the popup menu doesn't appear because of the brace at line
                      > > > >> > 1. Internally the script use the vim function "searchdecl" (same
                      > > > >> > behaviour as the command "gd") to search the declaration line of your
                      > > > >> > object "h". But "gd" works properly only if your brace starts a new
                      > > > >> > line because it uses internally the command "[[" (:help gd and :help
                      > > > >> > [[). So if you want to see the popup menu at line 4 you have to write
                      > > > >> > your code like this :
                      > > > >> >
                      > > > >> > 1 int main()
                      > > > >> > 2 { // This brace must starts the line
                      > > > >> > 3 hello h;
                      > > > >> > 4 hello::hello();
                      > > > >> > 5 h. // The popup menu should appear here
                      > > > >> > 6 hello::
                      > > > >> > 7 tmp1 t1;
                      > > > >> > 8 t1.
                      > > > >> > 9 }
                      > > > >> >
                      > > > >> > At line 8, the popup menu doesn't appear because, after the command
                      > > > >> > "gd", the script tokenizes the source code from line 5 to 7 and the
                      > > > >> > resulting code in our case is :
                      > > > >> >
                      > > > >> > h.hello::tmp1 t1;
                      > > > >> >
                      > > > >> > so the script found that the type of the object "t1" is
                      > > > >> > "h.hello::tmp1", this is not correct.
                      > > > >> > If you want to see the popup menu you have to, at least, terminate the
                      > > > >> > instruction at line 6 with ";"
                      > > > >> >
                      > > > >> > 1 int main()
                      > > > >> > 2 { // This brace must starts the line
                      > > > >> > 3 hello h;
                      > > > >> > 4 hello::hello();
                      > > > >> > 5 h.print(); // The popup menu should appear here
                      > > > >> > 6 hello::hello(); // you have to terminate properly your
                      > > > >> > // instruction with ";" before the next
                      > > > >> declaration
                      > > > >> > 7 tmp1 t1;
                      > > > >> > 8 t1. // the popup menu should appear here
                      > > > >> > 9 }
                      > > > >> >
                      > > > >> > If you have other questions, I am there :)
                      > > > >> >
                      > > > >> > Best regards,
                      > > > >> >
                      > > > >> > Vissale
                      > > > >> >
                      > > > >> > 2007/1/2, zhengda <zhengda1936@...>:
                      > > > >> > > Mikolaj Machowski wrote:
                      > > > >> > > > On pon sty 1 2007, Mikolaj Machowski wrote:
                      > > > >> > > >
                      > > > >> > > >> This won't work: you need a different variable name, see
                      > > > >> ":help E706".
                      > > > >> > > >>
                      > > > >> > > >
                      > > > >> > > > Yeah, I forgot (not only about that).
                      > > > >> > > >
                      > > > >> > > > This is complete solution::
                      > > > >> > > >
                      > > > >> > > > function! UpdateTags()
                      > > > >> > > > call writefile(getline(1, '$'), '.tmp.cc', 'b')
                      > > > >> > > > let tags = system('ctags --c++-kinds=+p --fields=+iaS
                      > > > >> --extra=+q -f
                      > > > >> > > > - .tmp.cc')
                      > > > >> > > > " Note: whitespaces around expand are tab chars.
                      > > > >> > > > let alltags = system('grep -v " '.expand('%').' "
                      > > > >> tags')
                      > > > >> > > > let tagstable = split(alltags, '\n')
                      > > > >> > > > call add(tagstable, tags)
                      > > > >> > > > call writefile(tagstable, 'tags', 'b')
                      > > > >> > > > redraw!
                      > > > >> > > > return ';'
                      > > > >> > > > endfunction
                      > > > >> > > > inoremap <expr> ; UpdateTags()
                      > > > >> > > >
                      > > > >> > > > Note: this is untested in real life, it doesn't return any errors.
                      > > > >> > > >
                      > > > >> > > > In good conditions execution of whole function takes 0.46s on
                      > > > >> big tags
                      > > > >> > > > file (KMail source, tags size over 4MB, 10000 lines). Delay
                      > > > >> noticeable
                      > > > >> > > > on my computer Sempron 2200, 512M RAM, old HD 5400rpm. In worse
                      > > > >> conditions
                      > > > >> > > > it was taking up to 0.75s::
                      > > > >> > > >
                      > > > >> > > > FUNCTION UpdateTags()
                      > > > >> > > > Called 1 time
                      > > > >> > > > Total time: 0.527128
                      > > > >> > > > Self time: 0.401542
                      > > > >> > > >
                      > > > >> > > > count total (s) self (s)
                      > > > >> > > > 1 0.000551 call writefile(getline(1,
                      > > > >> '$'), '.tmp.cc', 'b')
                      > > > >> > > > 1 0.026373 0.000298 let tags = system('ctags
                      > > > >> --c++-kinds=+p
                      > > > >> > > > --fields=+iaS --extra=+q -f - .tmp.cc')
                      > > > >> > > > 1 0.000091 let stags = split(tags,
                      > > > >> '\n')
                      > > > >> > > > 1 0.130731 0.031220 let alltags =
                      > > > >> system('grep -v " '.expand('%').' "
                      > > > >> > > > tags')
                      > > > >> > > > 1 0.128909 let tagstable =
                      > > > >> split(alltags, '\n')
                      > > > >> > > > 1 0.000043 call extend(tagstable,
                      > > > >> stags)
                      > > > >> > > > 1 0.240341 call writefile(tagstable,
                      > > > >> 'tags', 'b')
                      > > > >> > > > 1 0.000033 return ';'
                      > > > >> > > >
                      > > > >> > > > FUNCTIONS SORTED ON TOTAL TIME
                      > > > >> > > > count total (s) self (s) function
                      > > > >> > > > 1 0.527128 0.401542 UpdateTags()
                      > > > >> > > >
                      > > > >> > > > FUNCTIONS SORTED ON SELF TIME
                      > > > >> > > > count total (s) self (s) function
                      > > > >> > > > 1 0.527128 0.401542 UpdateTags()
                      > > > >> > > >
                      > > > >> > > > Note however I've made one fatal mistake. ``ctags fname`` will
                      > > > >> point to
                      > > > >> > > > tags in file .tmp.cc not our real current file! Filtering tags
                      > > > >> in Vim is
                      > > > >> > > > possible and on small sample quite fast but still 0.5s is long.
                      > > > >> Maybe we
                      > > > >> > > > should put that strain to the system::
                      > > > >> > > >
                      > > > >> > > > function! UpdateTags()
                      > > > >> > > > call writefile(getline(1, '$'), '.tmp.cc', 'b')
                      > > > >> > > > call system('grep -v " '.expand('%').' " tags >
                      > > > >> tags2 && mv -f tags2
                      > > > >> > > > tags')
                      > > > >> > > > let tags = system('ctags --c++-kinds=+p --fields=+iaS
                      > > > >> --extra=+q -f
                      > > > >> > > > - .tmp.cc | sed "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >> tags')
                      > > > >> > > > return ';'
                      > > > >> > > > endfunction
                      > > > >> > > > inoremap <expr> ; UpdateTags()
                      > > > >> > > >
                      > > > >> > > > And here we have the winner::
                      > > > >> > > >
                      > > > >> > > > FUNCTION UpdateTags()
                      > > > >> > > > Called 1 time
                      > > > >> > > > Total time: 0.145700
                      > > > >> > > > Self time: 0.001068
                      > > > >> > > >
                      > > > >> > > > count total (s) self (s)
                      > > > >> > > > 1 0.000523 call writefile(getline(1,
                      > > > >> '$'), '.tmp.cc', 'b')
                      > > > >> > > > 1 0.096118 0.000195 call system('grep -v "
                      > > > >> '.expand('%').' " tags >
                      > > > >> > > > tags2 && mv -f tags2 tags')
                      > > > >> > > > 1 0.049003 0.000294 call system('ctags
                      > > > >> --c++-kinds=+p --fields=+iaS
                      > > > >> > > > --extra=+q -f - .tmp.cc | sed
                      > > > >> "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >>
                      > > > >> > > > tags')
                      > > > >> > > > 1 0.000029 return ';'
                      > > > >> > > >
                      > > > >> > > > FUNCTIONS SORTED ON TOTAL TIME
                      > > > >> > > > count total (s) self (s) function
                      > > > >> > > > 1 0.145700 0.001068 UpdateTags()
                      > > > >> > > >
                      > > > >> > > > FUNCTIONS SORTED ON SELF TIME
                      > > > >> > > > count total (s) self (s) function
                      > > > >> > > > 1 0.145700 0.001068 UpdateTags()
                      > > > >> > > >
                      > > > >> > > >
                      > > > >> > > > Below 0.15s (and even in worse conditions only up to 0.25s)!
                      > > > >> This is
                      > > > >> > > > less then one keystroke of good touchtyper. This is for the
                      > > > >> price of
                      > > > >> > > > portability but you can find grep/sed/mv for other systems so
                      > > > >> situation
                      > > > >> > > > isn't hopeless.
                      > > > >> > > >
                      > > > >> > > > HTH
                      > > > >> > > >
                      > > > >> > > > m.
                      > > > >> > > >
                      > > > >> > > >
                      > > > >> > > >
                      > > > >> > > Thank you for your script. It doesn't work so fast in my computer.
                      > > > >> > > There is another problem when I use omnicppcomplete plugin.
                      > > > >> > > I don't know if it is its bug.
                      > > > >> > > For example, there are two files:
                      > > > >> > > --------tmp1.h--------------------
                      > > > >> > > class tmp1{
                      > > > >> > > public:
                      > > > >> > > void print1(){}
                      > > > >> > > };
                      > > > >> > > --------hello.cc-----------------
                      > > > >> > > #include "tmp1.h"
                      > > > >> > >
                      > > > >> > > class hello{
                      > > > >> > > public:
                      > > > >> > > void print(){}
                      > > > >> > > static void hello(){}
                      > > > >> > > static int h;
                      > > > >> > > };
                      > > > >> > >
                      > > > >> > > int main(){
                      > > > >> > > hello h;
                      > > > >> > > hello::hello();
                      > > > >> > > h.
                      > > > >> > > hello::<C-x><C-o> <--------- the popup menu only appear here
                      > > > >> > > tmp1 t1;
                      > > > >> > > t1.
                      > > > >> > > }
                      > > > >> > >
                      > > > >> > > I'm sure tags has been created correctly. The popup menu sometimes
                      > > > >> > > appears, sometimes doesn't when I type '.' or '->'.
                      > > > >> > > I tried many times, but still didn't find the rule: when it appears,
                      > > > >> > > when it doesn't.
                      > > > >> > > Does anyone meet the similar program? Or has some ideas?
                      > > > >> > >
                      > > > >> > > Zheng Da
                      > > > >> > >
                      > > > >> >
                      > > > >>
                      > > > >> Thank you for your reply.
                      > > > >> It does work in "h." in my case, when I changed the code like
                      > > > >> int main()
                      > > > >> {
                      > > > >> hello h;
                      > > > >> hello::hello();
                      > > > >> h.
                      > > > >> }
                      > > > >> But for class tmp1, it still doesn't work. For this code,
                      > > > >> ----------tmp1.h--------------
                      > > > >> class tmp1
                      > > > >> {
                      > > > >> public:
                      > > > >> void print1(){}
                      > > > >> };
                      > > > >> ----------hello.cc------------
                      > > > >> #include "tmp1.h"
                      > > > >>
                      > > > >> int main()
                      > > > >> {
                      > > > >> tmp1 t1;
                      > > > >> t1. <-----no popup menu appears
                      > > > >> }
                      > > > >> It seems it only works for the class in the same file.
                      > > > >> If the class is in the header file, it doesn't.
                      > > > >>
                      > > > >> --
                      > > > >> With regards
                      > > > >> Zheng Da
                      > > > >>
                      > > > These are my tags file and code files
                      > > >
                      > > >
                      > > > print1 tmp1.h /^ void print1(){}$/;" f class:tmp1 access:public signature:()
                      > > > tmp1 tmp1.h /^class tmp1$/;" c
                      > > > tmp1::print1 tmp1.h /^ void print1(){}$/;" f class:tmp1 access:public signature:()
                      > > > main test.cpp /^int main()$/;" f signature:()
                      > > >
                      > > >
                      > > >
                      > > >
                      > >
                      >
                      > Thank.
                      > But there will be a problem if I use the above script to update the tags file.
                      > I tried to use sort command, but it still doesn't work.
                      > If I have the code file as follow:
                      > ---------tmp1.h-----------
                      > class tmp1
                      > {
                      > public:
                      > void print1(){}
                      > };
                      > ---------test.cpp----------
                      > #include "tmp1.h"
                      >
                      > class world{
                      > public:
                      > void worldprint(){}
                      > };
                      >
                      > int main()
                      > {
                      > tmp1 t1;
                      > t1.
                      > }
                      >
                      > If I use the following function,
                      > function! SaveUpdateTags()
                      > write
                      > call system('grep -v "'.expand('%').'" tags > tags2')
                      > let tags = system('ctags --c++-kinds=+p --fields=+iaS --extra=+q -f -
                      > '.expand('%').' | sort >> tags2')
                      > call system('sort tags2>tags')
                      > call system('mv -f tags2 tags')
                      > return ''
                      > endfunc
                      >
                      > The tags file will be like this:
                      > main test.cpp /^int main()$/;" f signature:()
                      > print1 tmp1.h /^ void print1(){}$/;" f class:tmp1
                      > access:public signature:()
                      > tmp1::print1 tmp1.h /^ void print1(){}$/;" f class:tmp1
                      > access:public signature:()
                      > tmp1 tmp1.h /^class tmp1$/;" c
                      > worldprint test.cpp /^ void worldprint(){}$/;" f class:world
                      > access:public signature:()
                      > world test.cpp /^class world{$/;" c file:
                      > world::worldprint test.cpp /^ void worldprint(){}$/;" f
                      > class:world access:public signature:()
                      >
                      > How do I sort will make
                      > worldprint test.cpp /^ void worldprint(){}$/;" f class:world
                      > access:public signature:()
                      > below
                      > world test.cpp /^class world{$/;" c file:
                      >
                      >
                      > --
                      > With regards
                      > Zheng Da
                      >
                    • Zheng Da
                      ... The function is like this function! SaveUpdateTags() write call system( touch tags ) let othertags=system( grep -v .expand( % ). tags ) let currenttags
                      Message 10 of 27 , Jan 4, 2007
                      • 0 Attachment
                        On 1/4/07, Vissale NEANG <fromtonrouge@...> wrote:
                        > You can use the vim sort command (:help sort) instead of gnu sort.
                        > Moreover it's portable.
                        >
                        > 2007/1/4, Zheng Da <zhengda1936@...>:
                        > > On 1/4/07, Vissale NEANG <fromtonrouge@...> wrote:
                        > > > It's because your tag file is not sorted correctly, the last tag
                        > > > "main" should be the first tag in the file. The script does a tag
                        > > > binary search and the tags file must be sorted to work properly (:help
                        > > > tag-binary-search).
                        > > >
                        > > > Best regards,
                        > > >
                        > > > Vissale
                        > > >
                        > > > 2007/1/3, zhengda <zhengda1936@...>:
                        > > > > Vissale NEANG wrote:
                        > > > > > What is you ctags command?
                        > > > > > Could you send me your tag file?
                        > > > > >
                        > > > > > Just for comparison I give you my tag file
                        > > > > >
                        > > > > > 2007/1/3, Zheng Da <zhengda1936@...>:
                        > > > > >> On 1/3/07, Vissale NEANG <fromtonrouge@...> wrote:
                        > > > > >> > Hello,
                        > > > > >> >
                        > > > > >> > I am the maintainer of the script and I can reproduce the problem:
                        > > > > >> >
                        > > > > >> > 1 int main(){
                        > > > > >> > 2 hello h;
                        > > > > >> > 3 hello::hello();
                        > > > > >> > 4 h.
                        > > > > >> > 5 hello::<C-x><C-o> <--------- the popup menu only appear here
                        > > > > >> > 6 tmp1 t1;
                        > > > > >> > 7 t1.
                        > > > > >> > 8 }
                        > > > > >> >
                        > > > > >> > At line 4, the popup menu doesn't appear because of the brace at line
                        > > > > >> > 1. Internally the script use the vim function "searchdecl" (same
                        > > > > >> > behaviour as the command "gd") to search the declaration line of your
                        > > > > >> > object "h". But "gd" works properly only if your brace starts a new
                        > > > > >> > line because it uses internally the command "[[" (:help gd and :help
                        > > > > >> > [[). So if you want to see the popup menu at line 4 you have to write
                        > > > > >> > your code like this :
                        > > > > >> >
                        > > > > >> > 1 int main()
                        > > > > >> > 2 { // This brace must starts the line
                        > > > > >> > 3 hello h;
                        > > > > >> > 4 hello::hello();
                        > > > > >> > 5 h. // The popup menu should appear here
                        > > > > >> > 6 hello::
                        > > > > >> > 7 tmp1 t1;
                        > > > > >> > 8 t1.
                        > > > > >> > 9 }
                        > > > > >> >
                        > > > > >> > At line 8, the popup menu doesn't appear because, after the command
                        > > > > >> > "gd", the script tokenizes the source code from line 5 to 7 and the
                        > > > > >> > resulting code in our case is :
                        > > > > >> >
                        > > > > >> > h.hello::tmp1 t1;
                        > > > > >> >
                        > > > > >> > so the script found that the type of the object "t1" is
                        > > > > >> > "h.hello::tmp1", this is not correct.
                        > > > > >> > If you want to see the popup menu you have to, at least, terminate the
                        > > > > >> > instruction at line 6 with ";"
                        > > > > >> >
                        > > > > >> > 1 int main()
                        > > > > >> > 2 { // This brace must starts the line
                        > > > > >> > 3 hello h;
                        > > > > >> > 4 hello::hello();
                        > > > > >> > 5 h.print(); // The popup menu should appear here
                        > > > > >> > 6 hello::hello(); // you have to terminate properly your
                        > > > > >> > // instruction with ";" before the next
                        > > > > >> declaration
                        > > > > >> > 7 tmp1 t1;
                        > > > > >> > 8 t1. // the popup menu should appear here
                        > > > > >> > 9 }
                        > > > > >> >
                        > > > > >> > If you have other questions, I am there :)
                        > > > > >> >
                        > > > > >> > Best regards,
                        > > > > >> >
                        > > > > >> > Vissale
                        > > > > >> >
                        > > > > >> > 2007/1/2, zhengda <zhengda1936@...>:
                        > > > > >> > > Mikolaj Machowski wrote:
                        > > > > >> > > > On pon sty 1 2007, Mikolaj Machowski wrote:
                        > > > > >> > > >
                        > > > > >> > > >> This won't work: you need a different variable name, see
                        > > > > >> ":help E706".
                        > > > > >> > > >>
                        > > > > >> > > >
                        > > > > >> > > > Yeah, I forgot (not only about that).
                        > > > > >> > > >
                        > > > > >> > > > This is complete solution::
                        > > > > >> > > >
                        > > > > >> > > > function! UpdateTags()
                        > > > > >> > > > call writefile(getline(1, '$'), '.tmp.cc', 'b')
                        > > > > >> > > > let tags = system('ctags --c++-kinds=+p --fields=+iaS
                        > > > > >> --extra=+q -f
                        > > > > >> > > > - .tmp.cc')
                        > > > > >> > > > " Note: whitespaces around expand are tab chars.
                        > > > > >> > > > let alltags = system('grep -v " '.expand('%').' "
                        > > > > >> tags')
                        > > > > >> > > > let tagstable = split(alltags, '\n')
                        > > > > >> > > > call add(tagstable, tags)
                        > > > > >> > > > call writefile(tagstable, 'tags', 'b')
                        > > > > >> > > > redraw!
                        > > > > >> > > > return ';'
                        > > > > >> > > > endfunction
                        > > > > >> > > > inoremap <expr> ; UpdateTags()
                        > > > > >> > > >
                        > > > > >> > > > Note: this is untested in real life, it doesn't return any errors.
                        > > > > >> > > >
                        > > > > >> > > > In good conditions execution of whole function takes 0.46s on
                        > > > > >> big tags
                        > > > > >> > > > file (KMail source, tags size over 4MB, 10000 lines). Delay
                        > > > > >> noticeable
                        > > > > >> > > > on my computer Sempron 2200, 512M RAM, old HD 5400rpm. In worse
                        > > > > >> conditions
                        > > > > >> > > > it was taking up to 0.75s::
                        > > > > >> > > >
                        > > > > >> > > > FUNCTION UpdateTags()
                        > > > > >> > > > Called 1 time
                        > > > > >> > > > Total time: 0.527128
                        > > > > >> > > > Self time: 0.401542
                        > > > > >> > > >
                        > > > > >> > > > count total (s) self (s)
                        > > > > >> > > > 1 0.000551 call writefile(getline(1,
                        > > > > >> '$'), '.tmp.cc', 'b')
                        > > > > >> > > > 1 0.026373 0.000298 let tags = system('ctags
                        > > > > >> --c++-kinds=+p
                        > > > > >> > > > --fields=+iaS --extra=+q -f - .tmp.cc')
                        > > > > >> > > > 1 0.000091 let stags = split(tags,
                        > > > > >> '\n')
                        > > > > >> > > > 1 0.130731 0.031220 let alltags =
                        > > > > >> system('grep -v " '.expand('%').' "
                        > > > > >> > > > tags')
                        > > > > >> > > > 1 0.128909 let tagstable =
                        > > > > >> split(alltags, '\n')
                        > > > > >> > > > 1 0.000043 call extend(tagstable,
                        > > > > >> stags)
                        > > > > >> > > > 1 0.240341 call writefile(tagstable,
                        > > > > >> 'tags', 'b')
                        > > > > >> > > > 1 0.000033 return ';'
                        > > > > >> > > >
                        > > > > >> > > > FUNCTIONS SORTED ON TOTAL TIME
                        > > > > >> > > > count total (s) self (s) function
                        > > > > >> > > > 1 0.527128 0.401542 UpdateTags()
                        > > > > >> > > >
                        > > > > >> > > > FUNCTIONS SORTED ON SELF TIME
                        > > > > >> > > > count total (s) self (s) function
                        > > > > >> > > > 1 0.527128 0.401542 UpdateTags()
                        > > > > >> > > >
                        > > > > >> > > > Note however I've made one fatal mistake. ``ctags fname`` will
                        > > > > >> point to
                        > > > > >> > > > tags in file .tmp.cc not our real current file! Filtering tags
                        > > > > >> in Vim is
                        > > > > >> > > > possible and on small sample quite fast but still 0.5s is long.
                        > > > > >> Maybe we
                        > > > > >> > > > should put that strain to the system::
                        > > > > >> > > >
                        > > > > >> > > > function! UpdateTags()
                        > > > > >> > > > call writefile(getline(1, '$'), '.tmp.cc', 'b')
                        > > > > >> > > > call system('grep -v " '.expand('%').' " tags >
                        > > > > >> tags2 && mv -f tags2
                        > > > > >> > > > tags')
                        > > > > >> > > > let tags = system('ctags --c++-kinds=+p --fields=+iaS
                        > > > > >> --extra=+q -f
                        > > > > >> > > > - .tmp.cc | sed "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >> tags')
                        > > > > >> > > > return ';'
                        > > > > >> > > > endfunction
                        > > > > >> > > > inoremap <expr> ; UpdateTags()
                        > > > > >> > > >
                        > > > > >> > > > And here we have the winner::
                        > > > > >> > > >
                        > > > > >> > > > FUNCTION UpdateTags()
                        > > > > >> > > > Called 1 time
                        > > > > >> > > > Total time: 0.145700
                        > > > > >> > > > Self time: 0.001068
                        > > > > >> > > >
                        > > > > >> > > > count total (s) self (s)
                        > > > > >> > > > 1 0.000523 call writefile(getline(1,
                        > > > > >> '$'), '.tmp.cc', 'b')
                        > > > > >> > > > 1 0.096118 0.000195 call system('grep -v "
                        > > > > >> '.expand('%').' " tags >
                        > > > > >> > > > tags2 && mv -f tags2 tags')
                        > > > > >> > > > 1 0.049003 0.000294 call system('ctags
                        > > > > >> --c++-kinds=+p --fields=+iaS
                        > > > > >> > > > --extra=+q -f - .tmp.cc | sed
                        > > > > >> "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >>
                        > > > > >> > > > tags')
                        > > > > >> > > > 1 0.000029 return ';'
                        > > > > >> > > >
                        > > > > >> > > > FUNCTIONS SORTED ON TOTAL TIME
                        > > > > >> > > > count total (s) self (s) function
                        > > > > >> > > > 1 0.145700 0.001068 UpdateTags()
                        > > > > >> > > >
                        > > > > >> > > > FUNCTIONS SORTED ON SELF TIME
                        > > > > >> > > > count total (s) self (s) function
                        > > > > >> > > > 1 0.145700 0.001068 UpdateTags()
                        > > > > >> > > >
                        > > > > >> > > >
                        > > > > >> > > > Below 0.15s (and even in worse conditions only up to 0.25s)!
                        > > > > >> This is
                        > > > > >> > > > less then one keystroke of good touchtyper. This is for the
                        > > > > >> price of
                        > > > > >> > > > portability but you can find grep/sed/mv for other systems so
                        > > > > >> situation
                        > > > > >> > > > isn't hopeless.
                        > > > > >> > > >
                        > > > > >> > > > HTH
                        > > > > >> > > >
                        > > > > >> > > > m.
                        > > > > >> > > >
                        > > > > >> > > >
                        > > > > >> > > >
                        > > > > >> > > Thank you for your script. It doesn't work so fast in my computer.
                        > > > > >> > > There is another problem when I use omnicppcomplete plugin.
                        > > > > >> > > I don't know if it is its bug.
                        > > > > >> > > For example, there are two files:
                        > > > > >> > > --------tmp1.h--------------------
                        > > > > >> > > class tmp1{
                        > > > > >> > > public:
                        > > > > >> > > void print1(){}
                        > > > > >> > > };
                        > > > > >> > > --------hello.cc-----------------
                        > > > > >> > > #include "tmp1.h"
                        > > > > >> > >
                        > > > > >> > > class hello{
                        > > > > >> > > public:
                        > > > > >> > > void print(){}
                        > > > > >> > > static void hello(){}
                        > > > > >> > > static int h;
                        > > > > >> > > };
                        > > > > >> > >
                        > > > > >> > > int main(){
                        > > > > >> > > hello h;
                        > > > > >> > > hello::hello();
                        > > > > >> > > h.
                        > > > > >> > > hello::<C-x><C-o> <--------- the popup menu only appear here
                        > > > > >> > > tmp1 t1;
                        > > > > >> > > t1.
                        > > > > >> > > }
                        > > > > >> > >
                        > > > > >> > > I'm sure tags has been created correctly. The popup menu sometimes
                        > > > > >> > > appears, sometimes doesn't when I type '.' or '->'.
                        > > > > >> > > I tried many times, but still didn't find the rule: when it appears,
                        > > > > >> > > when it doesn't.
                        > > > > >> > > Does anyone meet the similar program? Or has some ideas?
                        > > > > >> > >
                        > > > > >> > > Zheng Da
                        > > > > >> > >
                        > > > > >> >
                        > > > > >>
                        > > > > >> Thank you for your reply.
                        > > > > >> It does work in "h." in my case, when I changed the code like
                        > > > > >> int main()
                        > > > > >> {
                        > > > > >> hello h;
                        > > > > >> hello::hello();
                        > > > > >> h.
                        > > > > >> }
                        > > > > >> But for class tmp1, it still doesn't work. For this code,
                        > > > > >> ----------tmp1.h--------------
                        > > > > >> class tmp1
                        > > > > >> {
                        > > > > >> public:
                        > > > > >> void print1(){}
                        > > > > >> };
                        > > > > >> ----------hello.cc------------
                        > > > > >> #include "tmp1.h"
                        > > > > >>
                        > > > > >> int main()
                        > > > > >> {
                        > > > > >> tmp1 t1;
                        > > > > >> t1. <-----no popup menu appears
                        > > > > >> }
                        > > > > >> It seems it only works for the class in the same file.
                        > > > > >> If the class is in the header file, it doesn't.
                        > > > > >>
                        > > > > >> --
                        > > > > >> With regards
                        > > > > >> Zheng Da
                        > > > > >>
                        > > > > These are my tags file and code files
                        > > > >
                        > > > >
                        > > > > print1 tmp1.h /^ void print1(){}$/;" f class:tmp1 access:public signature:()
                        > > > > tmp1 tmp1.h /^class tmp1$/;" c
                        > > > > tmp1::print1 tmp1.h /^ void print1(){}$/;" f class:tmp1 access:public signature:()
                        > > > > main test.cpp /^int main()$/;" f signature:()
                        > > > >
                        > > > >
                        > > > >
                        > > > >
                        > > >
                        > >
                        > > Thank.
                        > > But there will be a problem if I use the above script to update the tags file.
                        > > I tried to use sort command, but it still doesn't work.
                        > > If I have the code file as follow:
                        > > ---------tmp1.h-----------
                        > > class tmp1
                        > > {
                        > > public:
                        > > void print1(){}
                        > > };
                        > > ---------test.cpp----------
                        > > #include "tmp1.h"
                        > >
                        > > class world{
                        > > public:
                        > > void worldprint(){}
                        > > };
                        > >
                        > > int main()
                        > > {
                        > > tmp1 t1;
                        > > t1.
                        > > }
                        > >
                        > > If I use the following function,
                        > > function! SaveUpdateTags()
                        > > write
                        > > call system('grep -v "'.expand('%').'" tags > tags2')
                        > > let tags = system('ctags --c++-kinds=+p --fields=+iaS --extra=+q -f -
                        > > '.expand('%').' | sort >> tags2')
                        > > call system('sort tags2>tags')
                        > > call system('mv -f tags2 tags')
                        > > return ''
                        > > endfunc
                        > >
                        > > The tags file will be like this:
                        > > main test.cpp /^int main()$/;" f signature:()
                        > > print1 tmp1.h /^ void print1(){}$/;" f class:tmp1
                        > > access:public signature:()
                        > > tmp1::print1 tmp1.h /^ void print1(){}$/;" f class:tmp1
                        > > access:public signature:()
                        > > tmp1 tmp1.h /^class tmp1$/;" c
                        > > worldprint test.cpp /^ void worldprint(){}$/;" f class:world
                        > > access:public signature:()
                        > > world test.cpp /^class world{$/;" c file:
                        > > world::worldprint test.cpp /^ void worldprint(){}$/;" f
                        > > class:world access:public signature:()
                        > >
                        > > How do I sort will make
                        > > worldprint test.cpp /^ void worldprint(){}$/;" f class:world
                        > > access:public signature:()
                        > > below
                        > > world test.cpp /^class world{$/;" c file:
                        > >
                        > >
                        > > --
                        > > With regards
                        > > Zheng Da
                        > >
                        >

                        The function is like this
                        function! SaveUpdateTags()
                        write
                        call system('touch tags')
                        let othertags=system('grep -v "'.expand('%').'" tags')
                        let currenttags = system('ctags --c++-kinds=+p --fields=+iaS
                        --extra=+q -f - '.expand('%').'')
                        let newtags=split(othertags , "\n")+split(currenttags , "\n")
                        let sortedtags=sort(newtags)
                        call delete('tags')
                        call writefile(newtags , 'tags' , "b")
                        return ''
                        endfunc

                        It seems to work correctly, but I'm afraid it doesn't run fast for the
                        big project

                        --
                        With regards
                        Zheng Da
                      • Vissale NEANG
                        There is also an autotag plugin (just found it): http://www.vim.org/scripts/script.php?script_id=1343 But I have not yet try it. It seems you need to compile
                        Message 11 of 27 , Jan 4, 2007
                        • 0 Attachment
                          There is also an "autotag" plugin (just found it):

                          http://www.vim.org/scripts/script.php?script_id=1343

                          But I have not yet try it. It seems you need to compile vim with python.

                          2007/1/4, Zheng Da <zhengda1936@...>:
                          > On 1/4/07, Vissale NEANG <fromtonrouge@...> wrote:
                          > > You can use the vim sort command (:help sort) instead of gnu sort.
                          > > Moreover it's portable.
                          > >
                          > > 2007/1/4, Zheng Da <zhengda1936@...>:
                          > > > On 1/4/07, Vissale NEANG <fromtonrouge@...> wrote:
                          > > > > It's because your tag file is not sorted correctly, the last tag
                          > > > > "main" should be the first tag in the file. The script does a tag
                          > > > > binary search and the tags file must be sorted to work properly (:help
                          > > > > tag-binary-search).
                          > > > >
                          > > > > Best regards,
                          > > > >
                          > > > > Vissale
                          > > > >
                          > > > > 2007/1/3, zhengda <zhengda1936@...>:
                          > > > > > Vissale NEANG wrote:
                          > > > > > > What is you ctags command?
                          > > > > > > Could you send me your tag file?
                          > > > > > >
                          > > > > > > Just for comparison I give you my tag file
                          > > > > > >
                          > > > > > > 2007/1/3, Zheng Da <zhengda1936@...>:
                          > > > > > >> On 1/3/07, Vissale NEANG <fromtonrouge@...> wrote:
                          > > > > > >> > Hello,
                          > > > > > >> >
                          > > > > > >> > I am the maintainer of the script and I can reproduce the problem:
                          > > > > > >> >
                          > > > > > >> > 1 int main(){
                          > > > > > >> > 2 hello h;
                          > > > > > >> > 3 hello::hello();
                          > > > > > >> > 4 h.
                          > > > > > >> > 5 hello::<C-x><C-o> <--------- the popup menu only appear here
                          > > > > > >> > 6 tmp1 t1;
                          > > > > > >> > 7 t1.
                          > > > > > >> > 8 }
                          > > > > > >> >
                          > > > > > >> > At line 4, the popup menu doesn't appear because of the brace at line
                          > > > > > >> > 1. Internally the script use the vim function "searchdecl" (same
                          > > > > > >> > behaviour as the command "gd") to search the declaration line of your
                          > > > > > >> > object "h". But "gd" works properly only if your brace starts a new
                          > > > > > >> > line because it uses internally the command "[[" (:help gd and :help
                          > > > > > >> > [[). So if you want to see the popup menu at line 4 you have to write
                          > > > > > >> > your code like this :
                          > > > > > >> >
                          > > > > > >> > 1 int main()
                          > > > > > >> > 2 { // This brace must starts the line
                          > > > > > >> > 3 hello h;
                          > > > > > >> > 4 hello::hello();
                          > > > > > >> > 5 h. // The popup menu should appear here
                          > > > > > >> > 6 hello::
                          > > > > > >> > 7 tmp1 t1;
                          > > > > > >> > 8 t1.
                          > > > > > >> > 9 }
                          > > > > > >> >
                          > > > > > >> > At line 8, the popup menu doesn't appear because, after the command
                          > > > > > >> > "gd", the script tokenizes the source code from line 5 to 7 and the
                          > > > > > >> > resulting code in our case is :
                          > > > > > >> >
                          > > > > > >> > h.hello::tmp1 t1;
                          > > > > > >> >
                          > > > > > >> > so the script found that the type of the object "t1" is
                          > > > > > >> > "h.hello::tmp1", this is not correct.
                          > > > > > >> > If you want to see the popup menu you have to, at least, terminate the
                          > > > > > >> > instruction at line 6 with ";"
                          > > > > > >> >
                          > > > > > >> > 1 int main()
                          > > > > > >> > 2 { // This brace must starts the line
                          > > > > > >> > 3 hello h;
                          > > > > > >> > 4 hello::hello();
                          > > > > > >> > 5 h.print(); // The popup menu should appear here
                          > > > > > >> > 6 hello::hello(); // you have to terminate properly your
                          > > > > > >> > // instruction with ";" before the next
                          > > > > > >> declaration
                          > > > > > >> > 7 tmp1 t1;
                          > > > > > >> > 8 t1. // the popup menu should appear here
                          > > > > > >> > 9 }
                          > > > > > >> >
                          > > > > > >> > If you have other questions, I am there :)
                          > > > > > >> >
                          > > > > > >> > Best regards,
                          > > > > > >> >
                          > > > > > >> > Vissale
                          > > > > > >> >
                          > > > > > >> > 2007/1/2, zhengda <zhengda1936@...>:
                          > > > > > >> > > Mikolaj Machowski wrote:
                          > > > > > >> > > > On pon sty 1 2007, Mikolaj Machowski wrote:
                          > > > > > >> > > >
                          > > > > > >> > > >> This won't work: you need a different variable name, see
                          > > > > > >> ":help E706".
                          > > > > > >> > > >>
                          > > > > > >> > > >
                          > > > > > >> > > > Yeah, I forgot (not only about that).
                          > > > > > >> > > >
                          > > > > > >> > > > This is complete solution::
                          > > > > > >> > > >
                          > > > > > >> > > > function! UpdateTags()
                          > > > > > >> > > > call writefile(getline(1, '$'), '.tmp.cc', 'b')
                          > > > > > >> > > > let tags = system('ctags --c++-kinds=+p --fields=+iaS
                          > > > > > >> --extra=+q -f
                          > > > > > >> > > > - .tmp.cc')
                          > > > > > >> > > > " Note: whitespaces around expand are tab chars.
                          > > > > > >> > > > let alltags = system('grep -v " '.expand('%').' "
                          > > > > > >> tags')
                          > > > > > >> > > > let tagstable = split(alltags, '\n')
                          > > > > > >> > > > call add(tagstable, tags)
                          > > > > > >> > > > call writefile(tagstable, 'tags', 'b')
                          > > > > > >> > > > redraw!
                          > > > > > >> > > > return ';'
                          > > > > > >> > > > endfunction
                          > > > > > >> > > > inoremap <expr> ; UpdateTags()
                          > > > > > >> > > >
                          > > > > > >> > > > Note: this is untested in real life, it doesn't return any errors.
                          > > > > > >> > > >
                          > > > > > >> > > > In good conditions execution of whole function takes 0.46s on
                          > > > > > >> big tags
                          > > > > > >> > > > file (KMail source, tags size over 4MB, 10000 lines). Delay
                          > > > > > >> noticeable
                          > > > > > >> > > > on my computer Sempron 2200, 512M RAM, old HD 5400rpm. In worse
                          > > > > > >> conditions
                          > > > > > >> > > > it was taking up to 0.75s::
                          > > > > > >> > > >
                          > > > > > >> > > > FUNCTION UpdateTags()
                          > > > > > >> > > > Called 1 time
                          > > > > > >> > > > Total time: 0.527128
                          > > > > > >> > > > Self time: 0.401542
                          > > > > > >> > > >
                          > > > > > >> > > > count total (s) self (s)
                          > > > > > >> > > > 1 0.000551 call writefile(getline(1,
                          > > > > > >> '$'), '.tmp.cc', 'b')
                          > > > > > >> > > > 1 0.026373 0.000298 let tags = system('ctags
                          > > > > > >> --c++-kinds=+p
                          > > > > > >> > > > --fields=+iaS --extra=+q -f - .tmp.cc')
                          > > > > > >> > > > 1 0.000091 let stags = split(tags,
                          > > > > > >> '\n')
                          > > > > > >> > > > 1 0.130731 0.031220 let alltags =
                          > > > > > >> system('grep -v " '.expand('%').' "
                          > > > > > >> > > > tags')
                          > > > > > >> > > > 1 0.128909 let tagstable =
                          > > > > > >> split(alltags, '\n')
                          > > > > > >> > > > 1 0.000043 call extend(tagstable,
                          > > > > > >> stags)
                          > > > > > >> > > > 1 0.240341 call writefile(tagstable,
                          > > > > > >> 'tags', 'b')
                          > > > > > >> > > > 1 0.000033 return ';'
                          > > > > > >> > > >
                          > > > > > >> > > > FUNCTIONS SORTED ON TOTAL TIME
                          > > > > > >> > > > count total (s) self (s) function
                          > > > > > >> > > > 1 0.527128 0.401542 UpdateTags()
                          > > > > > >> > > >
                          > > > > > >> > > > FUNCTIONS SORTED ON SELF TIME
                          > > > > > >> > > > count total (s) self (s) function
                          > > > > > >> > > > 1 0.527128 0.401542 UpdateTags()
                          > > > > > >> > > >
                          > > > > > >> > > > Note however I've made one fatal mistake. ``ctags fname`` will
                          > > > > > >> point to
                          > > > > > >> > > > tags in file .tmp.cc not our real current file! Filtering tags
                          > > > > > >> in Vim is
                          > > > > > >> > > > possible and on small sample quite fast but still 0.5s is long.
                          > > > > > >> Maybe we
                          > > > > > >> > > > should put that strain to the system::
                          > > > > > >> > > >
                          > > > > > >> > > > function! UpdateTags()
                          > > > > > >> > > > call writefile(getline(1, '$'), '.tmp.cc', 'b')
                          > > > > > >> > > > call system('grep -v " '.expand('%').' " tags >
                          > > > > > >> tags2 && mv -f tags2
                          > > > > > >> > > > tags')
                          > > > > > >> > > > let tags = system('ctags --c++-kinds=+p --fields=+iaS
                          > > > > > >> --extra=+q -f
                          > > > > > >> > > > - .tmp.cc | sed "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >> tags')
                          > > > > > >> > > > return ';'
                          > > > > > >> > > > endfunction
                          > > > > > >> > > > inoremap <expr> ; UpdateTags()
                          > > > > > >> > > >
                          > > > > > >> > > > And here we have the winner::
                          > > > > > >> > > >
                          > > > > > >> > > > FUNCTION UpdateTags()
                          > > > > > >> > > > Called 1 time
                          > > > > > >> > > > Total time: 0.145700
                          > > > > > >> > > > Self time: 0.001068
                          > > > > > >> > > >
                          > > > > > >> > > > count total (s) self (s)
                          > > > > > >> > > > 1 0.000523 call writefile(getline(1,
                          > > > > > >> '$'), '.tmp.cc', 'b')
                          > > > > > >> > > > 1 0.096118 0.000195 call system('grep -v "
                          > > > > > >> '.expand('%').' " tags >
                          > > > > > >> > > > tags2 && mv -f tags2 tags')
                          > > > > > >> > > > 1 0.049003 0.000294 call system('ctags
                          > > > > > >> --c++-kinds=+p --fields=+iaS
                          > > > > > >> > > > --extra=+q -f - .tmp.cc | sed
                          > > > > > >> "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >>
                          > > > > > >> > > > tags')
                          > > > > > >> > > > 1 0.000029 return ';'
                          > > > > > >> > > >
                          > > > > > >> > > > FUNCTIONS SORTED ON TOTAL TIME
                          > > > > > >> > > > count total (s) self (s) function
                          > > > > > >> > > > 1 0.145700 0.001068 UpdateTags()
                          > > > > > >> > > >
                          > > > > > >> > > > FUNCTIONS SORTED ON SELF TIME
                          > > > > > >> > > > count total (s) self (s) function
                          > > > > > >> > > > 1 0.145700 0.001068 UpdateTags()
                          > > > > > >> > > >
                          > > > > > >> > > >
                          > > > > > >> > > > Below 0.15s (and even in worse conditions only up to 0.25s)!
                          > > > > > >> This is
                          > > > > > >> > > > less then one keystroke of good touchtyper. This is for the
                          > > > > > >> price of
                          > > > > > >> > > > portability but you can find grep/sed/mv for other systems so
                          > > > > > >> situation
                          > > > > > >> > > > isn't hopeless.
                          > > > > > >> > > >
                          > > > > > >> > > > HTH
                          > > > > > >> > > >
                          > > > > > >> > > > m.
                          > > > > > >> > > >
                          > > > > > >> > > >
                          > > > > > >> > > >
                          > > > > > >> > > Thank you for your script. It doesn't work so fast in my computer.
                          > > > > > >> > > There is another problem when I use omnicppcomplete plugin.
                          > > > > > >> > > I don't know if it is its bug.
                          > > > > > >> > > For example, there are two files:
                          > > > > > >> > > --------tmp1.h--------------------
                          > > > > > >> > > class tmp1{
                          > > > > > >> > > public:
                          > > > > > >> > > void print1(){}
                          > > > > > >> > > };
                          > > > > > >> > > --------hello.cc-----------------
                          > > > > > >> > > #include "tmp1.h"
                          > > > > > >> > >
                          > > > > > >> > > class hello{
                          > > > > > >> > > public:
                          > > > > > >> > > void print(){}
                          > > > > > >> > > static void hello(){}
                          > > > > > >> > > static int h;
                          > > > > > >> > > };
                          > > > > > >> > >
                          > > > > > >> > > int main(){
                          > > > > > >> > > hello h;
                          > > > > > >> > > hello::hello();
                          > > > > > >> > > h.
                          > > > > > >> > > hello::<C-x><C-o> <--------- the popup menu only appear here
                          > > > > > >> > > tmp1 t1;
                          > > > > > >> > > t1.
                          > > > > > >> > > }
                          > > > > > >> > >
                          > > > > > >> > > I'm sure tags has been created correctly. The popup menu sometimes
                          > > > > > >> > > appears, sometimes doesn't when I type '.' or '->'.
                          > > > > > >> > > I tried many times, but still didn't find the rule: when it appears,
                          > > > > > >> > > when it doesn't.
                          > > > > > >> > > Does anyone meet the similar program? Or has some ideas?
                          > > > > > >> > >
                          > > > > > >> > > Zheng Da
                          > > > > > >> > >
                          > > > > > >> >
                          > > > > > >>
                          > > > > > >> Thank you for your reply.
                          > > > > > >> It does work in "h." in my case, when I changed the code like
                          > > > > > >> int main()
                          > > > > > >> {
                          > > > > > >> hello h;
                          > > > > > >> hello::hello();
                          > > > > > >> h.
                          > > > > > >> }
                          > > > > > >> But for class tmp1, it still doesn't work. For this code,
                          > > > > > >> ----------tmp1.h--------------
                          > > > > > >> class tmp1
                          > > > > > >> {
                          > > > > > >> public:
                          > > > > > >> void print1(){}
                          > > > > > >> };
                          > > > > > >> ----------hello.cc------------
                          > > > > > >> #include "tmp1.h"
                          > > > > > >>
                          > > > > > >> int main()
                          > > > > > >> {
                          > > > > > >> tmp1 t1;
                          > > > > > >> t1. <-----no popup menu appears
                          > > > > > >> }
                          > > > > > >> It seems it only works for the class in the same file.
                          > > > > > >> If the class is in the header file, it doesn't.
                          > > > > > >>
                          > > > > > >> --
                          > > > > > >> With regards
                          > > > > > >> Zheng Da
                          > > > > > >>
                          > > > > > These are my tags file and code files
                          > > > > >
                          > > > > >
                          > > > > > print1 tmp1.h /^ void print1(){}$/;" f class:tmp1 access:public signature:()
                          > > > > > tmp1 tmp1.h /^class tmp1$/;" c
                          > > > > > tmp1::print1 tmp1.h /^ void print1(){}$/;" f class:tmp1 access:public signature:()
                          > > > > > main test.cpp /^int main()$/;" f signature:()
                          > > > > >
                          > > > > >
                          > > > > >
                          > > > > >
                          > > > >
                          > > >
                          > > > Thank.
                          > > > But there will be a problem if I use the above script to update the tags file.
                          > > > I tried to use sort command, but it still doesn't work.
                          > > > If I have the code file as follow:
                          > > > ---------tmp1.h-----------
                          > > > class tmp1
                          > > > {
                          > > > public:
                          > > > void print1(){}
                          > > > };
                          > > > ---------test.cpp----------
                          > > > #include "tmp1.h"
                          > > >
                          > > > class world{
                          > > > public:
                          > > > void worldprint(){}
                          > > > };
                          > > >
                          > > > int main()
                          > > > {
                          > > > tmp1 t1;
                          > > > t1.
                          > > > }
                          > > >
                          > > > If I use the following function,
                          > > > function! SaveUpdateTags()
                          > > > write
                          > > > call system('grep -v "'.expand('%').'" tags > tags2')
                          > > > let tags = system('ctags --c++-kinds=+p --fields=+iaS --extra=+q -f -
                          > > > '.expand('%').' | sort >> tags2')
                          > > > call system('sort tags2>tags')
                          > > > call system('mv -f tags2 tags')
                          > > > return ''
                          > > > endfunc
                          > > >
                          > > > The tags file will be like this:
                          > > > main test.cpp /^int main()$/;" f signature:()
                          > > > print1 tmp1.h /^ void print1(){}$/;" f class:tmp1
                          > > > access:public signature:()
                          > > > tmp1::print1 tmp1.h /^ void print1(){}$/;" f class:tmp1
                          > > > access:public signature:()
                          > > > tmp1 tmp1.h /^class tmp1$/;" c
                          > > > worldprint test.cpp /^ void worldprint(){}$/;" f class:world
                          > > > access:public signature:()
                          > > > world test.cpp /^class world{$/;" c file:
                          > > > world::worldprint test.cpp /^ void worldprint(){}$/;" f
                          > > > class:world access:public signature:()
                          > > >
                          > > > How do I sort will make
                          > > > worldprint test.cpp /^ void worldprint(){}$/;" f class:world
                          > > > access:public signature:()
                          > > > below
                          > > > world test.cpp /^class world{$/;" c file:
                          > > >
                          > > >
                          > > > --
                          > > > With regards
                          > > > Zheng Da
                          > > >
                          > >
                          >
                          > The function is like this
                          > function! SaveUpdateTags()
                          > write
                          > call system('touch tags')
                          > let othertags=system('grep -v "'.expand('%').'" tags')
                          > let currenttags = system('ctags --c++-kinds=+p --fields=+iaS
                          > --extra=+q -f - '.expand('%').'')
                          > let newtags=split(othertags , "\n")+split(currenttags , "\n")
                          > let sortedtags=sort(newtags)
                          > call delete('tags')
                          > call writefile(newtags , 'tags' , "b")
                          > return ''
                          > endfunc
                          >
                          > It seems to work correctly, but I'm afraid it doesn't run fast for the
                          > big project
                          >
                          > --
                          > With regards
                          > Zheng Da
                          >
                        • Zheng Da
                          ... Thank you for your help. By the way, how to compile vim with python. I run ./configure --enable-pythoninterp After I compiled vim and installed it, vim
                          Message 12 of 27 , Jan 4, 2007
                          • 0 Attachment
                            On 1/4/07, Vissale NEANG <fromtonrouge@...> wrote:
                            > There is also an "autotag" plugin (just found it):
                            >
                            > http://www.vim.org/scripts/script.php?script_id=1343
                            >
                            > But I have not yet try it. It seems you need to compile vim with python.
                            >
                            > 2007/1/4, Zheng Da <zhengda1936@...>:
                            > > On 1/4/07, Vissale NEANG <fromtonrouge@...> wrote:
                            > > > You can use the vim sort command (:help sort) instead of gnu sort.
                            > > > Moreover it's portable.
                            > > >
                            > > > 2007/1/4, Zheng Da <zhengda1936@...>:
                            > > > > On 1/4/07, Vissale NEANG <fromtonrouge@...> wrote:
                            > > > > > It's because your tag file is not sorted correctly, the last tag
                            > > > > > "main" should be the first tag in the file. The script does a tag
                            > > > > > binary search and the tags file must be sorted to work properly (:help
                            > > > > > tag-binary-search).
                            > > > > >
                            > > > > > Best regards,
                            > > > > >
                            > > > > > Vissale
                            > > > > >
                            > > > > > 2007/1/3, zhengda <zhengda1936@...>:
                            > > > > > > Vissale NEANG wrote:
                            > > > > > > > What is you ctags command?
                            > > > > > > > Could you send me your tag file?
                            > > > > > > >
                            > > > > > > > Just for comparison I give you my tag file
                            > > > > > > >
                            > > > > > > > 2007/1/3, Zheng Da <zhengda1936@...>:
                            > > > > > > >> On 1/3/07, Vissale NEANG <fromtonrouge@...> wrote:
                            > > > > > > >> > Hello,
                            > > > > > > >> >
                            > > > > > > >> > I am the maintainer of the script and I can reproduce the problem:
                            > > > > > > >> >
                            > > > > > > >> > 1 int main(){
                            > > > > > > >> > 2 hello h;
                            > > > > > > >> > 3 hello::hello();
                            > > > > > > >> > 4 h.
                            > > > > > > >> > 5 hello::<C-x><C-o> <--------- the popup menu only appear here
                            > > > > > > >> > 6 tmp1 t1;
                            > > > > > > >> > 7 t1.
                            > > > > > > >> > 8 }
                            > > > > > > >> >
                            > > > > > > >> > At line 4, the popup menu doesn't appear because of the brace at line
                            > > > > > > >> > 1. Internally the script use the vim function "searchdecl" (same
                            > > > > > > >> > behaviour as the command "gd") to search the declaration line of your
                            > > > > > > >> > object "h". But "gd" works properly only if your brace starts a new
                            > > > > > > >> > line because it uses internally the command "[[" (:help gd and :help
                            > > > > > > >> > [[). So if you want to see the popup menu at line 4 you have to write
                            > > > > > > >> > your code like this :
                            > > > > > > >> >
                            > > > > > > >> > 1 int main()
                            > > > > > > >> > 2 { // This brace must starts the line
                            > > > > > > >> > 3 hello h;
                            > > > > > > >> > 4 hello::hello();
                            > > > > > > >> > 5 h. // The popup menu should appear here
                            > > > > > > >> > 6 hello::
                            > > > > > > >> > 7 tmp1 t1;
                            > > > > > > >> > 8 t1.
                            > > > > > > >> > 9 }
                            > > > > > > >> >
                            > > > > > > >> > At line 8, the popup menu doesn't appear because, after the command
                            > > > > > > >> > "gd", the script tokenizes the source code from line 5 to 7 and the
                            > > > > > > >> > resulting code in our case is :
                            > > > > > > >> >
                            > > > > > > >> > h.hello::tmp1 t1;
                            > > > > > > >> >
                            > > > > > > >> > so the script found that the type of the object "t1" is
                            > > > > > > >> > "h.hello::tmp1", this is not correct.
                            > > > > > > >> > If you want to see the popup menu you have to, at least, terminate the
                            > > > > > > >> > instruction at line 6 with ";"
                            > > > > > > >> >
                            > > > > > > >> > 1 int main()
                            > > > > > > >> > 2 { // This brace must starts the line
                            > > > > > > >> > 3 hello h;
                            > > > > > > >> > 4 hello::hello();
                            > > > > > > >> > 5 h.print(); // The popup menu should appear here
                            > > > > > > >> > 6 hello::hello(); // you have to terminate properly your
                            > > > > > > >> > // instruction with ";" before the next
                            > > > > > > >> declaration
                            > > > > > > >> > 7 tmp1 t1;
                            > > > > > > >> > 8 t1. // the popup menu should appear here
                            > > > > > > >> > 9 }
                            > > > > > > >> >
                            > > > > > > >> > If you have other questions, I am there :)
                            > > > > > > >> >
                            > > > > > > >> > Best regards,
                            > > > > > > >> >
                            > > > > > > >> > Vissale
                            > > > > > > >> >
                            > > > > > > >> > 2007/1/2, zhengda <zhengda1936@...>:
                            > > > > > > >> > > Mikolaj Machowski wrote:
                            > > > > > > >> > > > On pon sty 1 2007, Mikolaj Machowski wrote:
                            > > > > > > >> > > >
                            > > > > > > >> > > >> This won't work: you need a different variable name, see
                            > > > > > > >> ":help E706".
                            > > > > > > >> > > >>
                            > > > > > > >> > > >
                            > > > > > > >> > > > Yeah, I forgot (not only about that).
                            > > > > > > >> > > >
                            > > > > > > >> > > > This is complete solution::
                            > > > > > > >> > > >
                            > > > > > > >> > > > function! UpdateTags()
                            > > > > > > >> > > > call writefile(getline(1, '$'), '.tmp.cc', 'b')
                            > > > > > > >> > > > let tags = system('ctags --c++-kinds=+p --fields=+iaS
                            > > > > > > >> --extra=+q -f
                            > > > > > > >> > > > - .tmp.cc')
                            > > > > > > >> > > > " Note: whitespaces around expand are tab chars.
                            > > > > > > >> > > > let alltags = system('grep -v " '.expand('%').' "
                            > > > > > > >> tags')
                            > > > > > > >> > > > let tagstable = split(alltags, '\n')
                            > > > > > > >> > > > call add(tagstable, tags)
                            > > > > > > >> > > > call writefile(tagstable, 'tags', 'b')
                            > > > > > > >> > > > redraw!
                            > > > > > > >> > > > return ';'
                            > > > > > > >> > > > endfunction
                            > > > > > > >> > > > inoremap <expr> ; UpdateTags()
                            > > > > > > >> > > >
                            > > > > > > >> > > > Note: this is untested in real life, it doesn't return any errors.
                            > > > > > > >> > > >
                            > > > > > > >> > > > In good conditions execution of whole function takes 0.46s on
                            > > > > > > >> big tags
                            > > > > > > >> > > > file (KMail source, tags size over 4MB, 10000 lines). Delay
                            > > > > > > >> noticeable
                            > > > > > > >> > > > on my computer Sempron 2200, 512M RAM, old HD 5400rpm. In worse
                            > > > > > > >> conditions
                            > > > > > > >> > > > it was taking up to 0.75s::
                            > > > > > > >> > > >
                            > > > > > > >> > > > FUNCTION UpdateTags()
                            > > > > > > >> > > > Called 1 time
                            > > > > > > >> > > > Total time: 0.527128
                            > > > > > > >> > > > Self time: 0.401542
                            > > > > > > >> > > >
                            > > > > > > >> > > > count total (s) self (s)
                            > > > > > > >> > > > 1 0.000551 call writefile(getline(1,
                            > > > > > > >> '$'), '.tmp.cc', 'b')
                            > > > > > > >> > > > 1 0.026373 0.000298 let tags = system('ctags
                            > > > > > > >> --c++-kinds=+p
                            > > > > > > >> > > > --fields=+iaS --extra=+q -f - .tmp.cc')
                            > > > > > > >> > > > 1 0.000091 let stags = split(tags,
                            > > > > > > >> '\n')
                            > > > > > > >> > > > 1 0.130731 0.031220 let alltags =
                            > > > > > > >> system('grep -v " '.expand('%').' "
                            > > > > > > >> > > > tags')
                            > > > > > > >> > > > 1 0.128909 let tagstable =
                            > > > > > > >> split(alltags, '\n')
                            > > > > > > >> > > > 1 0.000043 call extend(tagstable,
                            > > > > > > >> stags)
                            > > > > > > >> > > > 1 0.240341 call writefile(tagstable,
                            > > > > > > >> 'tags', 'b')
                            > > > > > > >> > > > 1 0.000033 return ';'
                            > > > > > > >> > > >
                            > > > > > > >> > > > FUNCTIONS SORTED ON TOTAL TIME
                            > > > > > > >> > > > count total (s) self (s) function
                            > > > > > > >> > > > 1 0.527128 0.401542 UpdateTags()
                            > > > > > > >> > > >
                            > > > > > > >> > > > FUNCTIONS SORTED ON SELF TIME
                            > > > > > > >> > > > count total (s) self (s) function
                            > > > > > > >> > > > 1 0.527128 0.401542 UpdateTags()
                            > > > > > > >> > > >
                            > > > > > > >> > > > Note however I've made one fatal mistake. ``ctags fname`` will
                            > > > > > > >> point to
                            > > > > > > >> > > > tags in file .tmp.cc not our real current file! Filtering tags
                            > > > > > > >> in Vim is
                            > > > > > > >> > > > possible and on small sample quite fast but still 0.5s is long.
                            > > > > > > >> Maybe we
                            > > > > > > >> > > > should put that strain to the system::
                            > > > > > > >> > > >
                            > > > > > > >> > > > function! UpdateTags()
                            > > > > > > >> > > > call writefile(getline(1, '$'), '.tmp.cc', 'b')
                            > > > > > > >> > > > call system('grep -v " '.expand('%').' " tags >
                            > > > > > > >> tags2 && mv -f tags2
                            > > > > > > >> > > > tags')
                            > > > > > > >> > > > let tags = system('ctags --c++-kinds=+p --fields=+iaS
                            > > > > > > >> --extra=+q -f
                            > > > > > > >> > > > - .tmp.cc | sed "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >> tags')
                            > > > > > > >> > > > return ';'
                            > > > > > > >> > > > endfunction
                            > > > > > > >> > > > inoremap <expr> ; UpdateTags()
                            > > > > > > >> > > >
                            > > > > > > >> > > > And here we have the winner::
                            > > > > > > >> > > >
                            > > > > > > >> > > > FUNCTION UpdateTags()
                            > > > > > > >> > > > Called 1 time
                            > > > > > > >> > > > Total time: 0.145700
                            > > > > > > >> > > > Self time: 0.001068
                            > > > > > > >> > > >
                            > > > > > > >> > > > count total (s) self (s)
                            > > > > > > >> > > > 1 0.000523 call writefile(getline(1,
                            > > > > > > >> '$'), '.tmp.cc', 'b')
                            > > > > > > >> > > > 1 0.096118 0.000195 call system('grep -v "
                            > > > > > > >> '.expand('%').' " tags >
                            > > > > > > >> > > > tags2 && mv -f tags2 tags')
                            > > > > > > >> > > > 1 0.049003 0.000294 call system('ctags
                            > > > > > > >> --c++-kinds=+p --fields=+iaS
                            > > > > > > >> > > > --extra=+q -f - .tmp.cc | sed
                            > > > > > > >> "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >>
                            > > > > > > >> > > > tags')
                            > > > > > > >> > > > 1 0.000029 return ';'
                            > > > > > > >> > > >
                            > > > > > > >> > > > FUNCTIONS SORTED ON TOTAL TIME
                            > > > > > > >> > > > count total (s) self (s) function
                            > > > > > > >> > > > 1 0.145700 0.001068 UpdateTags()
                            > > > > > > >> > > >
                            > > > > > > >> > > > FUNCTIONS SORTED ON SELF TIME
                            > > > > > > >> > > > count total (s) self (s) function
                            > > > > > > >> > > > 1 0.145700 0.001068 UpdateTags()
                            > > > > > > >> > > >
                            > > > > > > >> > > >
                            > > > > > > >> > > > Below 0.15s (and even in worse conditions only up to 0.25s)!
                            > > > > > > >> This is
                            > > > > > > >> > > > less then one keystroke of good touchtyper. This is for the
                            > > > > > > >> price of
                            > > > > > > >> > > > portability but you can find grep/sed/mv for other systems so
                            > > > > > > >> situation
                            > > > > > > >> > > > isn't hopeless.
                            > > > > > > >> > > >
                            > > > > > > >> > > > HTH
                            > > > > > > >> > > >
                            > > > > > > >> > > > m.
                            > > > > > > >> > > >
                            > > > > > > >> > > >
                            > > > > > > >> > > >
                            > > > > > > >> > > Thank you for your script. It doesn't work so fast in my computer.
                            > > > > > > >> > > There is another problem when I use omnicppcomplete plugin.
                            > > > > > > >> > > I don't know if it is its bug.
                            > > > > > > >> > > For example, there are two files:
                            > > > > > > >> > > --------tmp1.h--------------------
                            > > > > > > >> > > class tmp1{
                            > > > > > > >> > > public:
                            > > > > > > >> > > void print1(){}
                            > > > > > > >> > > };
                            > > > > > > >> > > --------hello.cc-----------------
                            > > > > > > >> > > #include "tmp1.h"
                            > > > > > > >> > >
                            > > > > > > >> > > class hello{
                            > > > > > > >> > > public:
                            > > > > > > >> > > void print(){}
                            > > > > > > >> > > static void hello(){}
                            > > > > > > >> > > static int h;
                            > > > > > > >> > > };
                            > > > > > > >> > >
                            > > > > > > >> > > int main(){
                            > > > > > > >> > > hello h;
                            > > > > > > >> > > hello::hello();
                            > > > > > > >> > > h.
                            > > > > > > >> > > hello::<C-x><C-o> <--------- the popup menu only appear here
                            > > > > > > >> > > tmp1 t1;
                            > > > > > > >> > > t1.
                            > > > > > > >> > > }
                            > > > > > > >> > >
                            > > > > > > >> > > I'm sure tags has been created correctly. The popup menu sometimes
                            > > > > > > >> > > appears, sometimes doesn't when I type '.' or '->'.
                            > > > > > > >> > > I tried many times, but still didn't find the rule: when it appears,
                            > > > > > > >> > > when it doesn't.
                            > > > > > > >> > > Does anyone meet the similar program? Or has some ideas?
                            > > > > > > >> > >
                            > > > > > > >> > > Zheng Da
                            > > > > > > >> > >
                            > > > > > > >> >
                            > > > > > > >>
                            > > > > > > >> Thank you for your reply.
                            > > > > > > >> It does work in "h." in my case, when I changed the code like
                            > > > > > > >> int main()
                            > > > > > > >> {
                            > > > > > > >> hello h;
                            > > > > > > >> hello::hello();
                            > > > > > > >> h.
                            > > > > > > >> }
                            > > > > > > >> But for class tmp1, it still doesn't work. For this code,
                            > > > > > > >> ----------tmp1.h--------------
                            > > > > > > >> class tmp1
                            > > > > > > >> {
                            > > > > > > >> public:
                            > > > > > > >> void print1(){}
                            > > > > > > >> };
                            > > > > > > >> ----------hello.cc------------
                            > > > > > > >> #include "tmp1.h"
                            > > > > > > >>
                            > > > > > > >> int main()
                            > > > > > > >> {
                            > > > > > > >> tmp1 t1;
                            > > > > > > >> t1. <-----no popup menu appears
                            > > > > > > >> }
                            > > > > > > >> It seems it only works for the class in the same file.
                            > > > > > > >> If the class is in the header file, it doesn't.
                            > > > > > > >>
                            > > > > > > >> --
                            > > > > > > >> With regards
                            > > > > > > >> Zheng Da
                            > > > > > > >>
                            > > > > > > These are my tags file and code files
                            > > > > > >
                            > > > > > >
                            > > > > > > print1 tmp1.h /^ void print1(){}$/;" f class:tmp1 access:public signature:()
                            > > > > > > tmp1 tmp1.h /^class tmp1$/;" c
                            > > > > > > tmp1::print1 tmp1.h /^ void print1(){}$/;" f class:tmp1 access:public signature:()
                            > > > > > > main test.cpp /^int main()$/;" f signature:()
                            > > > > > >
                            > > > > > >
                            > > > > > >
                            > > > > > >
                            > > > > >
                            > > > >
                            > > > > Thank.
                            > > > > But there will be a problem if I use the above script to update the tags file.
                            > > > > I tried to use sort command, but it still doesn't work.
                            > > > > If I have the code file as follow:
                            > > > > ---------tmp1.h-----------
                            > > > > class tmp1
                            > > > > {
                            > > > > public:
                            > > > > void print1(){}
                            > > > > };
                            > > > > ---------test.cpp----------
                            > > > > #include "tmp1.h"
                            > > > >
                            > > > > class world{
                            > > > > public:
                            > > > > void worldprint(){}
                            > > > > };
                            > > > >
                            > > > > int main()
                            > > > > {
                            > > > > tmp1 t1;
                            > > > > t1.
                            > > > > }
                            > > > >
                            > > > > If I use the following function,
                            > > > > function! SaveUpdateTags()
                            > > > > write
                            > > > > call system('grep -v "'.expand('%').'" tags > tags2')
                            > > > > let tags = system('ctags --c++-kinds=+p --fields=+iaS --extra=+q -f -
                            > > > > '.expand('%').' | sort >> tags2')
                            > > > > call system('sort tags2>tags')
                            > > > > call system('mv -f tags2 tags')
                            > > > > return ''
                            > > > > endfunc
                            > > > >
                            > > > > The tags file will be like this:
                            > > > > main test.cpp /^int main()$/;" f signature:()
                            > > > > print1 tmp1.h /^ void print1(){}$/;" f class:tmp1
                            > > > > access:public signature:()
                            > > > > tmp1::print1 tmp1.h /^ void print1(){}$/;" f class:tmp1
                            > > > > access:public signature:()
                            > > > > tmp1 tmp1.h /^class tmp1$/;" c
                            > > > > worldprint test.cpp /^ void worldprint(){}$/;" f class:world
                            > > > > access:public signature:()
                            > > > > world test.cpp /^class world{$/;" c file:
                            > > > > world::worldprint test.cpp /^ void worldprint(){}$/;" f
                            > > > > class:world access:public signature:()
                            > > > >
                            > > > > How do I sort will make
                            > > > > worldprint test.cpp /^ void worldprint(){}$/;" f class:world
                            > > > > access:public signature:()
                            > > > > below
                            > > > > world test.cpp /^class world{$/;" c file:
                            > > > >
                            > > > >
                            > > > > --
                            > > > > With regards
                            > > > > Zheng Da
                            > > > >
                            > > >
                            > >
                            > > The function is like this
                            > > function! SaveUpdateTags()
                            > > write
                            > > call system('touch tags')
                            > > let othertags=system('grep -v "'.expand('%').'" tags')
                            > > let currenttags = system('ctags --c++-kinds=+p --fields=+iaS
                            > > --extra=+q -f - '.expand('%').'')
                            > > let newtags=split(othertags , "\n")+split(currenttags , "\n")
                            > > let sortedtags=sort(newtags)
                            > > call delete('tags')
                            > > call writefile(newtags , 'tags' , "b")
                            > > return ''
                            > > endfunc
                            > >
                            > > It seems to work correctly, but I'm afraid it doesn't run fast for the
                            > > big project
                            > >
                            > > --
                            > > With regards
                            > > Zheng Da
                            > >
                            >

                            Thank you for your help.
                            By the way, how to compile vim with python.
                            I run ./configure --enable-pythoninterp
                            After I compiled vim and installed it,
                            "vim --version|grep python" still shows
                            -python +quickfix +reltime -rightleft -ruby +scrollbind +signs +smartindent

                            --
                            With regards
                            Zheng Da
                          • Zheng Da
                            This plugin seems to work well. Thank you so much Zheng Da ... -- With regards Zheng Da
                            Message 13 of 27 , Jan 4, 2007
                            • 0 Attachment
                              This plugin seems to work well.
                              Thank you so much

                              Zheng Da

                              On 1/4/07, Zheng Da <zhengda1936@...> wrote:
                              > On 1/4/07, Vissale NEANG <fromtonrouge@...> wrote:
                              > > There is also an "autotag" plugin (just found it):
                              > >
                              > > http://www.vim.org/scripts/script.php?script_id=1343
                              > >
                              > > But I have not yet try it. It seems you need to compile vim with python.
                              > >
                              > > 2007/1/4, Zheng Da <zhengda1936@...>:
                              > > > On 1/4/07, Vissale NEANG <fromtonrouge@...> wrote:
                              > > > > You can use the vim sort command (:help sort) instead of gnu sort.
                              > > > > Moreover it's portable.
                              > > > >
                              > > > > 2007/1/4, Zheng Da <zhengda1936@...>:
                              > > > > > On 1/4/07, Vissale NEANG <fromtonrouge@...> wrote:
                              > > > > > > It's because your tag file is not sorted correctly, the last tag
                              > > > > > > "main" should be the first tag in the file. The script does a tag
                              > > > > > > binary search and the tags file must be sorted to work properly (:help
                              > > > > > > tag-binary-search).
                              > > > > > >
                              > > > > > > Best regards,
                              > > > > > >
                              > > > > > > Vissale
                              > > > > > >
                              > > > > > > 2007/1/3, zhengda <zhengda1936@...>:
                              > > > > > > > Vissale NEANG wrote:
                              > > > > > > > > What is you ctags command?
                              > > > > > > > > Could you send me your tag file?
                              > > > > > > > >
                              > > > > > > > > Just for comparison I give you my tag file
                              > > > > > > > >
                              > > > > > > > > 2007/1/3, Zheng Da <zhengda1936@...>:
                              > > > > > > > >> On 1/3/07, Vissale NEANG <fromtonrouge@...> wrote:
                              > > > > > > > >> > Hello,
                              > > > > > > > >> >
                              > > > > > > > >> > I am the maintainer of the script and I can reproduce the problem:
                              > > > > > > > >> >
                              > > > > > > > >> > 1 int main(){
                              > > > > > > > >> > 2 hello h;
                              > > > > > > > >> > 3 hello::hello();
                              > > > > > > > >> > 4 h.
                              > > > > > > > >> > 5 hello::<C-x><C-o> <--------- the popup menu only appear here
                              > > > > > > > >> > 6 tmp1 t1;
                              > > > > > > > >> > 7 t1.
                              > > > > > > > >> > 8 }
                              > > > > > > > >> >
                              > > > > > > > >> > At line 4, the popup menu doesn't appear because of the brace at line
                              > > > > > > > >> > 1. Internally the script use the vim function "searchdecl" (same
                              > > > > > > > >> > behaviour as the command "gd") to search the declaration line of your
                              > > > > > > > >> > object "h". But "gd" works properly only if your brace starts a new
                              > > > > > > > >> > line because it uses internally the command "[[" (:help gd and :help
                              > > > > > > > >> > [[). So if you want to see the popup menu at line 4 you have to write
                              > > > > > > > >> > your code like this :
                              > > > > > > > >> >
                              > > > > > > > >> > 1 int main()
                              > > > > > > > >> > 2 { // This brace must starts the line
                              > > > > > > > >> > 3 hello h;
                              > > > > > > > >> > 4 hello::hello();
                              > > > > > > > >> > 5 h. // The popup menu should appear here
                              > > > > > > > >> > 6 hello::
                              > > > > > > > >> > 7 tmp1 t1;
                              > > > > > > > >> > 8 t1.
                              > > > > > > > >> > 9 }
                              > > > > > > > >> >
                              > > > > > > > >> > At line 8, the popup menu doesn't appear because, after the command
                              > > > > > > > >> > "gd", the script tokenizes the source code from line 5 to 7 and the
                              > > > > > > > >> > resulting code in our case is :
                              > > > > > > > >> >
                              > > > > > > > >> > h.hello::tmp1 t1;
                              > > > > > > > >> >
                              > > > > > > > >> > so the script found that the type of the object "t1" is
                              > > > > > > > >> > "h.hello::tmp1", this is not correct.
                              > > > > > > > >> > If you want to see the popup menu you have to, at least, terminate the
                              > > > > > > > >> > instruction at line 6 with ";"
                              > > > > > > > >> >
                              > > > > > > > >> > 1 int main()
                              > > > > > > > >> > 2 { // This brace must starts the line
                              > > > > > > > >> > 3 hello h;
                              > > > > > > > >> > 4 hello::hello();
                              > > > > > > > >> > 5 h.print(); // The popup menu should appear here
                              > > > > > > > >> > 6 hello::hello(); // you have to terminate properly your
                              > > > > > > > >> > // instruction with ";" before the next
                              > > > > > > > >> declaration
                              > > > > > > > >> > 7 tmp1 t1;
                              > > > > > > > >> > 8 t1. // the popup menu should appear here
                              > > > > > > > >> > 9 }
                              > > > > > > > >> >
                              > > > > > > > >> > If you have other questions, I am there :)
                              > > > > > > > >> >
                              > > > > > > > >> > Best regards,
                              > > > > > > > >> >
                              > > > > > > > >> > Vissale
                              > > > > > > > >> >
                              > > > > > > > >> > 2007/1/2, zhengda <zhengda1936@...>:
                              > > > > > > > >> > > Mikolaj Machowski wrote:
                              > > > > > > > >> > > > On pon sty 1 2007, Mikolaj Machowski wrote:
                              > > > > > > > >> > > >
                              > > > > > > > >> > > >> This won't work: you need a different variable name, see
                              > > > > > > > >> ":help E706".
                              > > > > > > > >> > > >>
                              > > > > > > > >> > > >
                              > > > > > > > >> > > > Yeah, I forgot (not only about that).
                              > > > > > > > >> > > >
                              > > > > > > > >> > > > This is complete solution::
                              > > > > > > > >> > > >
                              > > > > > > > >> > > > function! UpdateTags()
                              > > > > > > > >> > > > call writefile(getline(1, '$'), '.tmp.cc', 'b')
                              > > > > > > > >> > > > let tags = system('ctags --c++-kinds=+p --fields=+iaS
                              > > > > > > > >> --extra=+q -f
                              > > > > > > > >> > > > - .tmp.cc')
                              > > > > > > > >> > > > " Note: whitespaces around expand are tab chars.
                              > > > > > > > >> > > > let alltags = system('grep -v " '.expand('%').' "
                              > > > > > > > >> tags')
                              > > > > > > > >> > > > let tagstable = split(alltags, '\n')
                              > > > > > > > >> > > > call add(tagstable, tags)
                              > > > > > > > >> > > > call writefile(tagstable, 'tags', 'b')
                              > > > > > > > >> > > > redraw!
                              > > > > > > > >> > > > return ';'
                              > > > > > > > >> > > > endfunction
                              > > > > > > > >> > > > inoremap <expr> ; UpdateTags()
                              > > > > > > > >> > > >
                              > > > > > > > >> > > > Note: this is untested in real life, it doesn't return any errors.
                              > > > > > > > >> > > >
                              > > > > > > > >> > > > In good conditions execution of whole function takes 0.46s on
                              > > > > > > > >> big tags
                              > > > > > > > >> > > > file (KMail source, tags size over 4MB, 10000 lines). Delay
                              > > > > > > > >> noticeable
                              > > > > > > > >> > > > on my computer Sempron 2200, 512M RAM, old HD 5400rpm. In worse
                              > > > > > > > >> conditions
                              > > > > > > > >> > > > it was taking up to 0.75s::
                              > > > > > > > >> > > >
                              > > > > > > > >> > > > FUNCTION UpdateTags()
                              > > > > > > > >> > > > Called 1 time
                              > > > > > > > >> > > > Total time: 0.527128
                              > > > > > > > >> > > > Self time: 0.401542
                              > > > > > > > >> > > >
                              > > > > > > > >> > > > count total (s) self (s)
                              > > > > > > > >> > > > 1 0.000551 call writefile(getline(1,
                              > > > > > > > >> '$'), '.tmp.cc', 'b')
                              > > > > > > > >> > > > 1 0.026373 0.000298 let tags = system('ctags
                              > > > > > > > >> --c++-kinds=+p
                              > > > > > > > >> > > > --fields=+iaS --extra=+q -f - .tmp.cc')
                              > > > > > > > >> > > > 1 0.000091 let stags = split(tags,
                              > > > > > > > >> '\n')
                              > > > > > > > >> > > > 1 0.130731 0.031220 let alltags =
                              > > > > > > > >> system('grep -v " '.expand('%').' "
                              > > > > > > > >> > > > tags')
                              > > > > > > > >> > > > 1 0.128909 let tagstable =
                              > > > > > > > >> split(alltags, '\n')
                              > > > > > > > >> > > > 1 0.000043 call extend(tagstable,
                              > > > > > > > >> stags)
                              > > > > > > > >> > > > 1 0.240341 call writefile(tagstable,
                              > > > > > > > >> 'tags', 'b')
                              > > > > > > > >> > > > 1 0.000033 return ';'
                              > > > > > > > >> > > >
                              > > > > > > > >> > > > FUNCTIONS SORTED ON TOTAL TIME
                              > > > > > > > >> > > > count total (s) self (s) function
                              > > > > > > > >> > > > 1 0.527128 0.401542 UpdateTags()
                              > > > > > > > >> > > >
                              > > > > > > > >> > > > FUNCTIONS SORTED ON SELF TIME
                              > > > > > > > >> > > > count total (s) self (s) function
                              > > > > > > > >> > > > 1 0.527128 0.401542 UpdateTags()
                              > > > > > > > >> > > >
                              > > > > > > > >> > > > Note however I've made one fatal mistake. ``ctags fname`` will
                              > > > > > > > >> point to
                              > > > > > > > >> > > > tags in file .tmp.cc not our real current file! Filtering tags
                              > > > > > > > >> in Vim is
                              > > > > > > > >> > > > possible and on small sample quite fast but still 0.5s is long.
                              > > > > > > > >> Maybe we
                              > > > > > > > >> > > > should put that strain to the system::
                              > > > > > > > >> > > >
                              > > > > > > > >> > > > function! UpdateTags()
                              > > > > > > > >> > > > call writefile(getline(1, '$'), '.tmp.cc', 'b')
                              > > > > > > > >> > > > call system('grep -v " '.expand('%').' " tags >
                              > > > > > > > >> tags2 && mv -f tags2
                              > > > > > > > >> > > > tags')
                              > > > > > > > >> > > > let tags = system('ctags --c++-kinds=+p --fields=+iaS
                              > > > > > > > >> --extra=+q -f
                              > > > > > > > >> > > > - .tmp.cc | sed "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >> tags')
                              > > > > > > > >> > > > return ';'
                              > > > > > > > >> > > > endfunction
                              > > > > > > > >> > > > inoremap <expr> ; UpdateTags()
                              > > > > > > > >> > > >
                              > > > > > > > >> > > > And here we have the winner::
                              > > > > > > > >> > > >
                              > > > > > > > >> > > > FUNCTION UpdateTags()
                              > > > > > > > >> > > > Called 1 time
                              > > > > > > > >> > > > Total time: 0.145700
                              > > > > > > > >> > > > Self time: 0.001068
                              > > > > > > > >> > > >
                              > > > > > > > >> > > > count total (s) self (s)
                              > > > > > > > >> > > > 1 0.000523 call writefile(getline(1,
                              > > > > > > > >> '$'), '.tmp.cc', 'b')
                              > > > > > > > >> > > > 1 0.096118 0.000195 call system('grep -v "
                              > > > > > > > >> '.expand('%').' " tags >
                              > > > > > > > >> > > > tags2 && mv -f tags2 tags')
                              > > > > > > > >> > > > 1 0.049003 0.000294 call system('ctags
                              > > > > > > > >> --c++-kinds=+p --fields=+iaS
                              > > > > > > > >> > > > --extra=+q -f - .tmp.cc | sed
                              > > > > > > > >> "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >>
                              > > > > > > > >> > > > tags')
                              > > > > > > > >> > > > 1 0.000029 return ';'
                              > > > > > > > >> > > >
                              > > > > > > > >> > > > FUNCTIONS SORTED ON TOTAL TIME
                              > > > > > > > >> > > > count total (s) self (s) function
                              > > > > > > > >> > > > 1 0.145700 0.001068 UpdateTags()
                              > > > > > > > >> > > >
                              > > > > > > > >> > > > FUNCTIONS SORTED ON SELF TIME
                              > > > > > > > >> > > > count total (s) self (s) function
                              > > > > > > > >> > > > 1 0.145700 0.001068 UpdateTags()
                              > > > > > > > >> > > >
                              > > > > > > > >> > > >
                              > > > > > > > >> > > > Below 0.15s (and even in worse conditions only up to 0.25s)!
                              > > > > > > > >> This is
                              > > > > > > > >> > > > less then one keystroke of good touchtyper. This is for the
                              > > > > > > > >> price of
                              > > > > > > > >> > > > portability but you can find grep/sed/mv for other systems so
                              > > > > > > > >> situation
                              > > > > > > > >> > > > isn't hopeless.
                              > > > > > > > >> > > >
                              > > > > > > > >> > > > HTH
                              > > > > > > > >> > > >
                              > > > > > > > >> > > > m.
                              > > > > > > > >> > > >
                              > > > > > > > >> > > >
                              > > > > > > > >> > > >
                              > > > > > > > >> > > Thank you for your script. It doesn't work so fast in my computer.
                              > > > > > > > >> > > There is another problem when I use omnicppcomplete plugin.
                              > > > > > > > >> > > I don't know if it is its bug.
                              > > > > > > > >> > > For example, there are two files:
                              > > > > > > > >> > > --------tmp1.h--------------------
                              > > > > > > > >> > > class tmp1{
                              > > > > > > > >> > > public:
                              > > > > > > > >> > > void print1(){}
                              > > > > > > > >> > > };
                              > > > > > > > >> > > --------hello.cc-----------------
                              > > > > > > > >> > > #include "tmp1.h"
                              > > > > > > > >> > >
                              > > > > > > > >> > > class hello{
                              > > > > > > > >> > > public:
                              > > > > > > > >> > > void print(){}
                              > > > > > > > >> > > static void hello(){}
                              > > > > > > > >> > > static int h;
                              > > > > > > > >> > > };
                              > > > > > > > >> > >
                              > > > > > > > >> > > int main(){
                              > > > > > > > >> > > hello h;
                              > > > > > > > >> > > hello::hello();
                              > > > > > > > >> > > h.
                              > > > > > > > >> > > hello::<C-x><C-o> <--------- the popup menu only appear here
                              > > > > > > > >> > > tmp1 t1;
                              > > > > > > > >> > > t1.
                              > > > > > > > >> > > }
                              > > > > > > > >> > >
                              > > > > > > > >> > > I'm sure tags has been created correctly. The popup menu sometimes
                              > > > > > > > >> > > appears, sometimes doesn't when I type '.' or '->'.
                              > > > > > > > >> > > I tried many times, but still didn't find the rule: when it appears,
                              > > > > > > > >> > > when it doesn't.
                              > > > > > > > >> > > Does anyone meet the similar program? Or has some ideas?
                              > > > > > > > >> > >
                              > > > > > > > >> > > Zheng Da
                              > > > > > > > >> > >
                              > > > > > > > >> >
                              > > > > > > > >>
                              > > > > > > > >> Thank you for your reply.
                              > > > > > > > >> It does work in "h." in my case, when I changed the code like
                              > > > > > > > >> int main()
                              > > > > > > > >> {
                              > > > > > > > >> hello h;
                              > > > > > > > >> hello::hello();
                              > > > > > > > >> h.
                              > > > > > > > >> }
                              > > > > > > > >> But for class tmp1, it still doesn't work. For this code,
                              > > > > > > > >> ----------tmp1.h--------------
                              > > > > > > > >> class tmp1
                              > > > > > > > >> {
                              > > > > > > > >> public:
                              > > > > > > > >> void print1(){}
                              > > > > > > > >> };
                              > > > > > > > >> ----------hello.cc------------
                              > > > > > > > >> #include "tmp1.h"
                              > > > > > > > >>
                              > > > > > > > >> int main()
                              > > > > > > > >> {
                              > > > > > > > >> tmp1 t1;
                              > > > > > > > >> t1. <-----no popup menu appears
                              > > > > > > > >> }
                              > > > > > > > >> It seems it only works for the class in the same file.
                              > > > > > > > >> If the class is in the header file, it doesn't.
                              > > > > > > > >>
                              > > > > > > > >> --
                              > > > > > > > >> With regards
                              > > > > > > > >> Zheng Da
                              > > > > > > > >>
                              > > > > > > > These are my tags file and code files
                              > > > > > > >
                              > > > > > > >
                              > > > > > > > print1 tmp1.h /^ void print1(){}$/;" f class:tmp1 access:public signature:()
                              > > > > > > > tmp1 tmp1.h /^class tmp1$/;" c
                              > > > > > > > tmp1::print1 tmp1.h /^ void print1(){}$/;" f class:tmp1 access:public signature:()
                              > > > > > > > main test.cpp /^int main()$/;" f signature:()
                              > > > > > > >
                              > > > > > > >
                              > > > > > > >
                              > > > > > > >
                              > > > > > >
                              > > > > >
                              > > > > > Thank.
                              > > > > > But there will be a problem if I use the above script to update the tags file.
                              > > > > > I tried to use sort command, but it still doesn't work.
                              > > > > > If I have the code file as follow:
                              > > > > > ---------tmp1.h-----------
                              > > > > > class tmp1
                              > > > > > {
                              > > > > > public:
                              > > > > > void print1(){}
                              > > > > > };
                              > > > > > ---------test.cpp----------
                              > > > > > #include "tmp1.h"
                              > > > > >
                              > > > > > class world{
                              > > > > > public:
                              > > > > > void worldprint(){}
                              > > > > > };
                              > > > > >
                              > > > > > int main()
                              > > > > > {
                              > > > > > tmp1 t1;
                              > > > > > t1.
                              > > > > > }
                              > > > > >
                              > > > > > If I use the following function,
                              > > > > > function! SaveUpdateTags()
                              > > > > > write
                              > > > > > call system('grep -v "'.expand('%').'" tags > tags2')
                              > > > > > let tags = system('ctags --c++-kinds=+p --fields=+iaS --extra=+q -f -
                              > > > > > '.expand('%').' | sort >> tags2')
                              > > > > > call system('sort tags2>tags')
                              > > > > > call system('mv -f tags2 tags')
                              > > > > > return ''
                              > > > > > endfunc
                              > > > > >
                              > > > > > The tags file will be like this:
                              > > > > > main test.cpp /^int main()$/;" f signature:()
                              > > > > > print1 tmp1.h /^ void print1(){}$/;" f class:tmp1
                              > > > > > access:public signature:()
                              > > > > > tmp1::print1 tmp1.h /^ void print1(){}$/;" f class:tmp1
                              > > > > > access:public signature:()
                              > > > > > tmp1 tmp1.h /^class tmp1$/;" c
                              > > > > > worldprint test.cpp /^ void worldprint(){}$/;" f class:world
                              > > > > > access:public signature:()
                              > > > > > world test.cpp /^class world{$/;" c file:
                              > > > > > world::worldprint test.cpp /^ void worldprint(){}$/;" f
                              > > > > > class:world access:public signature:()
                              > > > > >
                              > > > > > How do I sort will make
                              > > > > > worldprint test.cpp /^ void worldprint(){}$/;" f class:world
                              > > > > > access:public signature:()
                              > > > > > below
                              > > > > > world test.cpp /^class world{$/;" c file:
                              > > > > >
                              > > > > >
                              > > > > > --
                              > > > > > With regards
                              > > > > > Zheng Da
                              > > > > >
                              > > > >
                              > > >
                              > > > The function is like this
                              > > > function! SaveUpdateTags()
                              > > > write
                              > > > call system('touch tags')
                              > > > let othertags=system('grep -v "'.expand('%').'" tags')
                              > > > let currenttags = system('ctags --c++-kinds=+p --fields=+iaS
                              > > > --extra=+q -f - '.expand('%').'')
                              > > > let newtags=split(othertags , "\n")+split(currenttags , "\n")
                              > > > let sortedtags=sort(newtags)
                              > > > call delete('tags')
                              > > > call writefile(newtags , 'tags' , "b")
                              > > > return ''
                              > > > endfunc
                              > > >
                              > > > It seems to work correctly, but I'm afraid it doesn't run fast for the
                              > > > big project
                              > > >
                              > > > --
                              > > > With regards
                              > > > Zheng Da
                              > > >
                              > >
                              >
                              > Thank you for your help.
                              > By the way, how to compile vim with python.
                              > I run ./configure --enable-pythoninterp
                              > After I compiled vim and installed it,
                              > "vim --version|grep python" still shows
                              > -python +quickfix +reltime -rightleft -ruby +scrollbind +signs +smartindent
                              >
                              > --
                              > With regards
                              > Zheng Da
                              >


                              --
                              With regards
                              Zheng Da
                            • A.J.Mechelynck
                              ... 1. Make sure each tag line is one line, not several as in this mail. 2. Use either of the following: 2a) Method I: in a Unix (*sh) or Dos (COMMAND.COM,
                              Message 14 of 27 , Jan 4, 2007
                              • 0 Attachment
                                Zheng Da wrote:
                                > On 1/4/07, Vissale NEANG <fromtonrouge@...> wrote:
                                >> It's because your tag file is not sorted correctly, the last tag
                                >> "main" should be the first tag in the file. The script does a tag
                                >> binary search and the tags file must be sorted to work properly (:help
                                >> tag-binary-search).
                                >>
                                >> Best regards,
                                >>
                                >> Vissale
                                >>
                                >> 2007/1/3, zhengda <zhengda1936@...>:
                                >> > Vissale NEANG wrote:
                                >> > > What is you ctags command?
                                >> > > Could you send me your tag file?
                                >> > >
                                >> > > Just for comparison I give you my tag file
                                >> > >
                                >> > > 2007/1/3, Zheng Da <zhengda1936@...>:
                                >> > >> On 1/3/07, Vissale NEANG <fromtonrouge@...> wrote:
                                >> > >> > Hello,
                                >> > >> >
                                >> > >> > I am the maintainer of the script and I can reproduce the problem:
                                >> > >> >
                                >> > >> > 1 int main(){
                                >> > >> > 2 hello h;
                                >> > >> > 3 hello::hello();
                                >> > >> > 4 h.
                                >> > >> > 5 hello::<C-x><C-o> <--------- the popup menu only appear
                                >> here
                                >> > >> > 6 tmp1 t1;
                                >> > >> > 7 t1.
                                >> > >> > 8 }
                                >> > >> >
                                >> > >> > At line 4, the popup menu doesn't appear because of the brace
                                >> at line
                                >> > >> > 1. Internally the script use the vim function "searchdecl" (same
                                >> > >> > behaviour as the command "gd") to search the declaration line
                                >> of your
                                >> > >> > object "h". But "gd" works properly only if your brace starts a
                                >> new
                                >> > >> > line because it uses internally the command "[[" (:help gd and
                                >> :help
                                >> > >> > [[). So if you want to see the popup menu at line 4 you have to
                                >> write
                                >> > >> > your code like this :
                                >> > >> >
                                >> > >> > 1 int main()
                                >> > >> > 2 { // This brace must starts the line
                                >> > >> > 3 hello h;
                                >> > >> > 4 hello::hello();
                                >> > >> > 5 h. // The popup menu should appear here
                                >> > >> > 6 hello::
                                >> > >> > 7 tmp1 t1;
                                >> > >> > 8 t1.
                                >> > >> > 9 }
                                >> > >> >
                                >> > >> > At line 8, the popup menu doesn't appear because, after the
                                >> command
                                >> > >> > "gd", the script tokenizes the source code from line 5 to 7 and
                                >> the
                                >> > >> > resulting code in our case is :
                                >> > >> >
                                >> > >> > h.hello::tmp1 t1;
                                >> > >> >
                                >> > >> > so the script found that the type of the object "t1" is
                                >> > >> > "h.hello::tmp1", this is not correct.
                                >> > >> > If you want to see the popup menu you have to, at least,
                                >> terminate the
                                >> > >> > instruction at line 6 with ";"
                                >> > >> >
                                >> > >> > 1 int main()
                                >> > >> > 2 { // This brace must starts the line
                                >> > >> > 3 hello h;
                                >> > >> > 4 hello::hello();
                                >> > >> > 5 h.print(); // The popup menu should appear here
                                >> > >> > 6 hello::hello(); // you have to terminate properly your
                                >> > >> > // instruction with ";" before the next
                                >> > >> declaration
                                >> > >> > 7 tmp1 t1;
                                >> > >> > 8 t1. // the popup menu should appear here
                                >> > >> > 9 }
                                >> > >> >
                                >> > >> > If you have other questions, I am there :)
                                >> > >> >
                                >> > >> > Best regards,
                                >> > >> >
                                >> > >> > Vissale
                                >> > >> >
                                >> > >> > 2007/1/2, zhengda <zhengda1936@...>:
                                >> > >> > > Mikolaj Machowski wrote:
                                >> > >> > > > On pon sty 1 2007, Mikolaj Machowski wrote:
                                >> > >> > > >
                                >> > >> > > >> This won't work: you need a different variable name, see
                                >> > >> ":help E706".
                                >> > >> > > >>
                                >> > >> > > >
                                >> > >> > > > Yeah, I forgot (not only about that).
                                >> > >> > > >
                                >> > >> > > > This is complete solution::
                                >> > >> > > >
                                >> > >> > > > function! UpdateTags()
                                >> > >> > > > call writefile(getline(1, '$'), '.tmp.cc', 'b')
                                >> > >> > > > let tags = system('ctags --c++-kinds=+p
                                >> --fields=+iaS
                                >> > >> --extra=+q -f
                                >> > >> > > > - .tmp.cc')
                                >> > >> > > > " Note: whitespaces around expand are tab chars.
                                >> > >> > > > let alltags = system('grep -v "
                                >> '.expand('%').' "
                                >> > >> tags')
                                >> > >> > > > let tagstable = split(alltags, '\n')
                                >> > >> > > > call add(tagstable, tags)
                                >> > >> > > > call writefile(tagstable, 'tags', 'b')
                                >> > >> > > > redraw!
                                >> > >> > > > return ';'
                                >> > >> > > > endfunction
                                >> > >> > > > inoremap <expr> ; UpdateTags()
                                >> > >> > > >
                                >> > >> > > > Note: this is untested in real life, it doesn't return any
                                >> errors.
                                >> > >> > > >
                                >> > >> > > > In good conditions execution of whole function takes 0.46s on
                                >> > >> big tags
                                >> > >> > > > file (KMail source, tags size over 4MB, 10000 lines). Delay
                                >> > >> noticeable
                                >> > >> > > > on my computer Sempron 2200, 512M RAM, old HD 5400rpm. In
                                >> worse
                                >> > >> conditions
                                >> > >> > > > it was taking up to 0.75s::
                                >> > >> > > >
                                >> > >> > > > FUNCTION UpdateTags()
                                >> > >> > > > Called 1 time
                                >> > >> > > > Total time: 0.527128
                                >> > >> > > > Self time: 0.401542
                                >> > >> > > >
                                >> > >> > > > count total (s) self (s)
                                >> > >> > > > 1 0.000551 call
                                >> writefile(getline(1,
                                >> > >> '$'), '.tmp.cc', 'b')
                                >> > >> > > > 1 0.026373 0.000298 let tags = system('ctags
                                >> > >> --c++-kinds=+p
                                >> > >> > > > --fields=+iaS --extra=+q -f - .tmp.cc')
                                >> > >> > > > 1 0.000091 let stags = split(tags,
                                >> > >> '\n')
                                >> > >> > > > 1 0.130731 0.031220 let alltags =
                                >> > >> system('grep -v " '.expand('%').' "
                                >> > >> > > > tags')
                                >> > >> > > > 1 0.128909 let tagstable =
                                >> > >> split(alltags, '\n')
                                >> > >> > > > 1 0.000043 call extend(tagstable,
                                >> > >> stags)
                                >> > >> > > > 1 0.240341 call
                                >> writefile(tagstable,
                                >> > >> 'tags', 'b')
                                >> > >> > > > 1 0.000033 return ';'
                                >> > >> > > >
                                >> > >> > > > FUNCTIONS SORTED ON TOTAL TIME
                                >> > >> > > > count total (s) self (s) function
                                >> > >> > > > 1 0.527128 0.401542 UpdateTags()
                                >> > >> > > >
                                >> > >> > > > FUNCTIONS SORTED ON SELF TIME
                                >> > >> > > > count total (s) self (s) function
                                >> > >> > > > 1 0.527128 0.401542 UpdateTags()
                                >> > >> > > >
                                >> > >> > > > Note however I've made one fatal mistake. ``ctags fname`` will
                                >> > >> point to
                                >> > >> > > > tags in file .tmp.cc not our real current file! Filtering tags
                                >> > >> in Vim is
                                >> > >> > > > possible and on small sample quite fast but still 0.5s is
                                >> long.
                                >> > >> Maybe we
                                >> > >> > > > should put that strain to the system::
                                >> > >> > > >
                                >> > >> > > > function! UpdateTags()
                                >> > >> > > > call writefile(getline(1, '$'), '.tmp.cc', 'b')
                                >> > >> > > > call system('grep -v " '.expand('%').' " tags >
                                >> > >> tags2 && mv -f tags2
                                >> > >> > > > tags')
                                >> > >> > > > let tags = system('ctags --c++-kinds=+p
                                >> --fields=+iaS
                                >> > >> --extra=+q -f
                                >> > >> > > > - .tmp.cc | sed "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >>
                                >> tags')
                                >> > >> > > > return ';'
                                >> > >> > > > endfunction
                                >> > >> > > > inoremap <expr> ; UpdateTags()
                                >> > >> > > >
                                >> > >> > > > And here we have the winner::
                                >> > >> > > >
                                >> > >> > > > FUNCTION UpdateTags()
                                >> > >> > > > Called 1 time
                                >> > >> > > > Total time: 0.145700
                                >> > >> > > > Self time: 0.001068
                                >> > >> > > >
                                >> > >> > > > count total (s) self (s)
                                >> > >> > > > 1 0.000523 call
                                >> writefile(getline(1,
                                >> > >> '$'), '.tmp.cc', 'b')
                                >> > >> > > > 1 0.096118 0.000195 call system('grep -v "
                                >> > >> '.expand('%').' " tags >
                                >> > >> > > > tags2 && mv -f tags2 tags')
                                >> > >> > > > 1 0.049003 0.000294 call system('ctags
                                >> > >> --c++-kinds=+p --fields=+iaS
                                >> > >> > > > --extra=+q -f - .tmp.cc | sed
                                >> > >> "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >>
                                >> > >> > > > tags')
                                >> > >> > > > 1 0.000029 return ';'
                                >> > >> > > >
                                >> > >> > > > FUNCTIONS SORTED ON TOTAL TIME
                                >> > >> > > > count total (s) self (s) function
                                >> > >> > > > 1 0.145700 0.001068 UpdateTags()
                                >> > >> > > >
                                >> > >> > > > FUNCTIONS SORTED ON SELF TIME
                                >> > >> > > > count total (s) self (s) function
                                >> > >> > > > 1 0.145700 0.001068 UpdateTags()
                                >> > >> > > >
                                >> > >> > > >
                                >> > >> > > > Below 0.15s (and even in worse conditions only up to 0.25s)!
                                >> > >> This is
                                >> > >> > > > less then one keystroke of good touchtyper. This is for the
                                >> > >> price of
                                >> > >> > > > portability but you can find grep/sed/mv for other systems so
                                >> > >> situation
                                >> > >> > > > isn't hopeless.
                                >> > >> > > >
                                >> > >> > > > HTH
                                >> > >> > > >
                                >> > >> > > > m.
                                >> > >> > > >
                                >> > >> > > >
                                >> > >> > > >
                                >> > >> > > Thank you for your script. It doesn't work so fast in my
                                >> computer.
                                >> > >> > > There is another problem when I use omnicppcomplete plugin.
                                >> > >> > > I don't know if it is its bug.
                                >> > >> > > For example, there are two files:
                                >> > >> > > --------tmp1.h--------------------
                                >> > >> > > class tmp1{
                                >> > >> > > public:
                                >> > >> > > void print1(){}
                                >> > >> > > };
                                >> > >> > > --------hello.cc-----------------
                                >> > >> > > #include "tmp1.h"
                                >> > >> > >
                                >> > >> > > class hello{
                                >> > >> > > public:
                                >> > >> > > void print(){}
                                >> > >> > > static void hello(){}
                                >> > >> > > static int h;
                                >> > >> > > };
                                >> > >> > >
                                >> > >> > > int main(){
                                >> > >> > > hello h;
                                >> > >> > > hello::hello();
                                >> > >> > > h.
                                >> > >> > > hello::<C-x><C-o> <--------- the popup menu only appear
                                >> here
                                >> > >> > > tmp1 t1;
                                >> > >> > > t1.
                                >> > >> > > }
                                >> > >> > >
                                >> > >> > > I'm sure tags has been created correctly. The popup menu
                                >> sometimes
                                >> > >> > > appears, sometimes doesn't when I type '.' or '->'.
                                >> > >> > > I tried many times, but still didn't find the rule: when it
                                >> appears,
                                >> > >> > > when it doesn't.
                                >> > >> > > Does anyone meet the similar program? Or has some ideas?
                                >> > >> > >
                                >> > >> > > Zheng Da
                                >> > >> > >
                                >> > >> >
                                >> > >>
                                >> > >> Thank you for your reply.
                                >> > >> It does work in "h." in my case, when I changed the code like
                                >> > >> int main()
                                >> > >> {
                                >> > >> hello h;
                                >> > >> hello::hello();
                                >> > >> h.
                                >> > >> }
                                >> > >> But for class tmp1, it still doesn't work. For this code,
                                >> > >> ----------tmp1.h--------------
                                >> > >> class tmp1
                                >> > >> {
                                >> > >> public:
                                >> > >> void print1(){}
                                >> > >> };
                                >> > >> ----------hello.cc------------
                                >> > >> #include "tmp1.h"
                                >> > >>
                                >> > >> int main()
                                >> > >> {
                                >> > >> tmp1 t1;
                                >> > >> t1. <-----no popup menu appears
                                >> > >> }
                                >> > >> It seems it only works for the class in the same file.
                                >> > >> If the class is in the header file, it doesn't.
                                >> > >>
                                >> > >> --
                                >> > >> With regards
                                >> > >> Zheng Da
                                >> > >>
                                >> > These are my tags file and code files
                                >> >
                                >> >
                                >> > print1 tmp1.h /^ void print1(){}$/;" f
                                >> class:tmp1 access:public signature:()
                                >> > tmp1 tmp1.h /^class tmp1$/;" c
                                >> > tmp1::print1 tmp1.h /^ void print1(){}$/;" f
                                >> class:tmp1 access:public signature:()
                                >> > main test.cpp /^int main()$/;" f signature:()
                                >> >
                                >> >
                                >> >
                                >> >
                                >>
                                >
                                > Thank.
                                > But there will be a problem if I use the above script to update the tags
                                > file.
                                > I tried to use sort command, but it still doesn't work.
                                > If I have the code file as follow:
                                > ---------tmp1.h-----------
                                > class tmp1
                                > {
                                > public:
                                > void print1(){}
                                > };
                                > ---------test.cpp----------
                                > #include "tmp1.h"
                                >
                                > class world{
                                > public:
                                > void worldprint(){}
                                > };
                                >
                                > int main()
                                > {
                                > tmp1 t1;
                                > t1.
                                > }
                                >
                                > If I use the following function,
                                > function! SaveUpdateTags()
                                > write
                                > call system('grep -v "'.expand('%').'" tags > tags2')
                                > let tags = system('ctags --c++-kinds=+p --fields=+iaS --extra=+q -f -
                                > '.expand('%').' | sort >> tags2')
                                > call system('sort tags2>tags')
                                > call system('mv -f tags2 tags')
                                > return ''
                                > endfunc
                                >
                                > The tags file will be like this:
                                > main test.cpp /^int main()$/;" f signature:()
                                > print1 tmp1.h /^ void print1(){}$/;" f class:tmp1
                                > access:public signature:()
                                > tmp1::print1 tmp1.h /^ void print1(){}$/;" f class:tmp1
                                > access:public signature:()
                                > tmp1 tmp1.h /^class tmp1$/;" c
                                > worldprint test.cpp /^ void worldprint(){}$/;" f class:world
                                > access:public signature:()
                                > world test.cpp /^class world{$/;" c file:
                                > world::worldprint test.cpp /^ void worldprint(){}$/;" f
                                > class:world access:public signature:()
                                >
                                > How do I sort will make
                                > worldprint test.cpp /^ void worldprint(){}$/;" f class:world
                                > access:public signature:()
                                > below
                                > world test.cpp /^class world{$/;" c file:
                                >
                                >

                                1. Make sure each tag line is one line, not several as in this mail.

                                2. Use either of the following:
                                2a) Method I: in a Unix (*sh) or Dos (COMMAND.COM, CMD.EXE) shell
                                sort < oldfile > newfile

                                where oldfile and newfile are the filenames before and after sorting,
                                respectively. To sort the "tags" file in-place:

                                (Unix)
                                cp tags oldtags
                                sort < oldtags > tags
                                rm -f oldtags
                                (Dos)
                                copy tags oldtags
                                sort < oldtags > tags
                                del /Y oldtags

                                2b) Method II: in Vim
                                :e tags
                                :sort


                                Best regards,
                                Tony.
                              • A.J.Mechelynck
                                Zheng Da wrote: [...] ... In order to be able to compile Vim with Python, you need not only the Python runtime libraries (usually the python package or
                                Message 15 of 27 , Jan 4, 2007
                                • 0 Attachment
                                  Zheng Da wrote:
                                  [...]
                                  > By the way, how to compile vim with python.
                                  > I run ./configure --enable-pythoninterp
                                  > After I compiled vim and installed it,
                                  > "vim --version|grep python" still shows
                                  > -python +quickfix +reltime -rightleft -ruby +scrollbind +signs +smartindent
                                  >

                                  In order to be able to compile Vim with Python, you need not only the Python
                                  runtime libraries (usually the "python" package or something like that) but
                                  also the Python header files ("python-dev" or "python-devel" package).

                                  Best regards,
                                  Tony.
                                • vuthecuong
                                  In windows, this command au GUIEnter * simalt ~x will make gvim window to become maximize. How about in freebsd? When I used above command in freebsd, it
                                  Message 16 of 27 , Jan 7, 2007
                                  • 0 Attachment
                                    In windows, this command " au GUIEnter * simalt ~x " will
                                    make gvim window to become maximize.
                                    How about in freebsd? When I used above command in freebsd,
                                    it cannot maximize
                                    Thanks in advanced
                                  • A.J.Mechelynck
                                    ... :simalt ~x simulates Alt-Space x , invoking that menu, if there is any. It is not cross-language, and, as you saw, not always cross-platform. The
                                    Message 17 of 27 , Jan 7, 2007
                                    • 0 Attachment
                                      vuthecuong wrote:
                                      > In windows, this command " au GUIEnter * simalt ~x " will
                                      > make gvim window to become maximize.
                                      > How about in freebsd? When I used above command in freebsd,
                                      > it cannot maximize
                                      > Thanks in advanced
                                      >
                                      >
                                      >

                                      ":simalt ~x" simulates "Alt-Space x", invoking that menu, if there is any. It
                                      is not cross-language, and, as you saw, not always cross-platform.

                                      The command

                                      if has("gui_running")
                                      set lines=9999 columns=9999
                                      endif

                                      will enlarge the GUI screen to within one character cell of the OS viewport.

                                      Ordering of statements may be important:
                                      1) set 'guifont' (which changes the character cell's pixel size)
                                      2) set 'lines' and 'columns'
                                      3) set '(no)equalalways', 'winheight', 'winminheight' etc. (which depend on
                                      the Vim screen size).


                                      Best regards,
                                      Tony.
                                    • Vu The Cuong
                                      thanks for quick response :D ... From: A.J.Mechelynck [mailto:antoine.mechelynck@skynet.be] Sent: Monday, January 08, 2007 7:33 AM To: vuthecuong Cc:
                                      Message 18 of 27 , Jan 7, 2007
                                      • 0 Attachment
                                        thanks for quick response :D


                                        -----Original Message-----
                                        From: A.J.Mechelynck [mailto:antoine.mechelynck@...]
                                        Sent: Monday, January 08, 2007 7:33 AM
                                        To: vuthecuong
                                        Cc: vim@...
                                        Subject: Re: gvim window maximize in freebsd6

                                        vuthecuong wrote:
                                        > In windows, this command " au GUIEnter * simalt ~x " will make gvim
                                        > window to become maximize.
                                        > How about in freebsd? When I used above command in freebsd, it cannot
                                        > maximize Thanks in advanced
                                        >
                                        >
                                        >

                                        ":simalt ~x" simulates "Alt-Space x", invoking that menu, if there is
                                        any. It is not cross-language, and, as you saw, not always
                                        cross-platform.

                                        The command

                                        if has("gui_running")
                                        set lines=9999 columns=9999
                                        endif

                                        will enlarge the GUI screen to within one character cell of the OS
                                        viewport.

                                        Ordering of statements may be important:
                                        1) set 'guifont' (which changes the character cell's pixel size)
                                        2) set 'lines' and 'columns'
                                        3) set '(no)equalalways', 'winheight', 'winminheight' etc. (which depend
                                        on the Vim screen size).


                                        Best regards,
                                        Tony.
                                      Your message has been successfully submitted and would be delivered to recipients shortly.