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

automatic code completion in vim

Expand Messages
  • zhengda
    Hello, I hope vim can run automatically a completion after a . , - or :: when I write c++ program. I know omnicppcomplete plugin can do this job. But
    Message 1 of 27 , Dec 29, 2006
    • 0 Attachment
      Hello,

      I hope vim can run automatically a completion after a '.', '->' or '::'
      when I write c++ program. I know omnicppcomplete plugin can do this job.
      But omnicppcomplete needs tag database. So if I want omnicppcomplete to
      tell me members of a class, I have to keep updating the tag database
      even though I only make a little change.
      So is there other ways to do the completion? Or is there some way to let
      omnicppcomplete update the tag database automatically?

      Zheng Da
    • Mikolaj Machowski
      ... Some time ago I was experimenting with PHP files and remapping of ; to recreate tags file including changes from current file (even when non-written). On
      Message 2 of 27 , Dec 30, 2006
      • 0 Attachment
        On sob gru 30 2006, vim@... wrote:
        > Hello,
        >
        > I hope vim can run automatically a completion after a '.', '->' or '::'
        > when I write c++ program. I know omnicppcomplete plugin can do this job.
        > But omnicppcomplete needs tag database. So if I want omnicppcomplete to
        > tell me members of a class, I have to keep updating the tag database
        > even though I only make a little change.
        > So is there other ways to do the completion? Or is there some way to let
        > omnicppcomplete update the tag database automatically?

        Some time ago I was experimenting with PHP files and remapping of ; to
        recreate tags file including changes from current file (even when
        non-written). On big projects it was taking too much time. On small to
        middle ones behaviour was acceptable.

        You could try similar thing or better: create tags only for current
        file and later replace proper entries in project tags file. Should give
        significant speed gains comparing to my approach.

        m.
      • Zheng Da
        Do you mean create tags files for every code file, and change tags file when switching between different code files? But how to combine all of these actions to
        Message 3 of 27 , Dec 30, 2006
        • 0 Attachment
          Do you mean create tags files for every code file, and change tags
          file when switching between different code files?
          But how to combine all of these actions to a hotkey?
          If ctags can provide an update option, the problem can be solved very easily.
          But it seems ctags doesn't provide this option any longer.

          Zheng Da

          On 12/30/06, Mikolaj Machowski <mikmach@...> wrote:
          > On sob gru 30 2006, vim@... wrote:
          > > Hello,
          > >
          > > I hope vim can run automatically a completion after a '.', '->' or '::'
          > > when I write c++ program. I know omnicppcomplete plugin can do this job.
          > > But omnicppcomplete needs tag database. So if I want omnicppcomplete to
          > > tell me members of a class, I have to keep updating the tag database
          > > even though I only make a little change.
          > > So is there other ways to do the completion? Or is there some way to let
          > > omnicppcomplete update the tag database automatically?
          >
          > Some time ago I was experimenting with PHP files and remapping of ; to
          > recreate tags file including changes from current file (even when
          > non-written). On big projects it was taking too much time. On small to
          > middle ones behaviour was acceptable.
          >
          > You could try similar thing or better: create tags only for current
          > file and later replace proper entries in project tags file. Should give
          > significant speed gains comparing to my approach.
          >
          > m.
          >
          >


          --
          With regards
          Zheng Da
        • Mikolaj Machowski
          ... No. It should looks like this: 1. Map common key to action. For language like C++ ; (semicolon) is good choice (eg. for Python it should be ). 2.
          Message 4 of 27 , Dec 30, 2006
          • 0 Attachment
            On sob gru 30 2006, Mikolaj Machowski wrote:
            > Do you mean create tags files for every code file, and change tags
            > file when switching between different code files?
            > But how to combine all of these actions to a hotkey?
            > If ctags can provide an update option, the problem can be solved very
            > easily. But it seems ctags doesn't provide this option any longer.

            No. It should looks like this:

            1. Map common key to action. For language like C++ ";" (semicolon) is
            good choice (eg. for Python it should be <CR>).
            2. inoremap it to function which will insert ; and perform some
            function.
            3. This function should:

            a) get contents of file (:help getline())
            b) write it to temporary file (:help writefile, :help tempname; wide
            workaround but we don't want to write current file, it could break
            some things)
            c) execute ctags on that file (:help system(), man ctags - you can
            get tags directly into variable (note: this is string)::

            :let a = system('ctags -f - '.file)

            Good thing would be to remove header of tags file (lines beginning
            with '!').

            Now we have file with updated definitions of tags for current file.
            Rest depends on how do you organize your tags files. Lets assume you
            have one big tags file for whole project.

            d) find tags file (:help 'tags' and check how omnicomplete functions
            are finding tags files)
            e) read this file (:help readfile())
            f) delete lines containing definitions from current file (:help :for,
            :help remove())
            g) connect your new tags and global tags
            h) overwrite old tags file.

            Note: much faster, noticeable on big files, would be reading of tags
            file into buffer and just g//d proper lines and add tags at the end
            - but I hate buffer management in scripts, YMMV.

            Sounds complicated but Vim should be able to perform all actions with
            reasonable speed. The most expensive is f) .

            You should carefully consider when this function should be performed.
            I would vote for ; and BufLeave and BufWritePre autocommands.

            m.
          • dong wang
            but i remember that , the (enhanced) ctags do have the option to append the tag files. you can see the manual more seriously , so i think you can find it
            Message 5 of 27 , Dec 30, 2006
            • 0 Attachment
              but i remember that , the (enhanced) ctags do have the option to
              append the tag files.
              you can see the manual more seriously , so i think you can find it " --append"

              I don't know whether this could be suit for you , but you can try it.


              2006/12/31, Zheng Da <zhengda1936@...>:
              > Do you mean create tags files for every code file, and change tags
              > file when switching between different code files?
              > But how to combine all of these actions to a hotkey?
              > If ctags can provide an update option, the problem can be solved very easily.
              > But it seems ctags doesn't provide this option any longer.
              >
              > Zheng Da
              >
              > On 12/30/06, Mikolaj Machowski <mikmach@...> wrote:
              > > On sob gru 30 2006, vim@... wrote:
              > > > Hello,
              > > >
              > > > I hope vim can run automatically a completion after a '.', '->' or '::'
              > > > when I write c++ program. I know omnicppcomplete plugin can do this job.
              > > > But omnicppcomplete needs tag database. So if I want omnicppcomplete to
              > > > tell me members of a class, I have to keep updating the tag database
              > > > even though I only make a little change.
              > > > So is there other ways to do the completion? Or is there some way to let
              > > > omnicppcomplete update the tag database automatically?
              > >
              > > Some time ago I was experimenting with PHP files and remapping of ; to
              > > recreate tags file including changes from current file (even when
              > > non-written). On big projects it was taking too much time. On small to
              > > middle ones behaviour was acceptable.
              > >
              > > You could try similar thing or better: create tags only for current
              > > file and later replace proper entries in project tags file. Should give
              > > significant speed gains comparing to my approach.
              > >
              > > m.
              > >
              > >
              >
              >
              > --
              > With regards
              > Zheng Da
              >
            • Mikolaj Machowski
              ... Yes, but they are not removing older entries. When doing corrections in file it may result with wrong suggestions - no longer existing in source. m.
              Message 6 of 27 , Dec 31, 2006
              • 0 Attachment
                On nie gru 31 2006, Zheng Da wrote:
                > but i remember that , the (enhanced) ctags do have the option to
                > append the tag files.
                > you can see the manual more seriously , so i think you can find it "
                > --append"

                Yes, but they are not removing older entries. When doing corrections in
                file it may result with wrong suggestions - no longer existing in source.

                m.
              • zhengda
                ... how to read tags into the buffer and what does g//d proper lines mean? ... I write the function like this, but there are some problems. This is my first
                Message 7 of 27 , Dec 31, 2006
                • 0 Attachment
                  Mikolaj Machowski wrote:
                  > On sob gru 30 2006, Mikolaj Machowski wrote:
                  >
                  >> Do you mean create tags files for every code file, and change tags
                  >> file when switching between different code files?
                  >> But how to combine all of these actions to a hotkey?
                  >> If ctags can provide an update option, the problem can be solved very
                  >> easily. But it seems ctags doesn't provide this option any longer.
                  >>
                  >
                  > No. It should looks like this:
                  >
                  > 1. Map common key to action. For language like C++ ";" (semicolon) is
                  > good choice (eg. for Python it should be <CR>).
                  > 2. inoremap it to function which will insert ; and perform some
                  > function.
                  > 3. This function should:
                  >
                  > a) get contents of file (:help getline())
                  > b) write it to temporary file (:help writefile, :help tempname; wide
                  > workaround but we don't want to write current file, it could break
                  > some things)
                  > c) execute ctags on that file (:help system(), man ctags - you can
                  > get tags directly into variable (note: this is string)::
                  >
                  > :let a = system('ctags -f - '.file)
                  >
                  > Good thing would be to remove header of tags file (lines beginning
                  > with '!').
                  >
                  > Now we have file with updated definitions of tags for current file.
                  > Rest depends on how do you organize your tags files. Lets assume you
                  > have one big tags file for whole project.
                  >
                  > d) find tags file (:help 'tags' and check how omnicomplete functions
                  > are finding tags files)
                  > e) read this file (:help readfile())
                  > f) delete lines containing definitions from current file (:help :for,
                  > :help remove())
                  > g) connect your new tags and global tags
                  > h) overwrite old tags file.
                  >
                  > Note: much faster, noticeable on big files, would be reading of tags
                  > file into buffer and just g//d proper lines and add tags at the end
                  >
                  how to read tags into the buffer and what does "g//d proper lines" mean?
                  > - but I hate buffer management in scripts, YMMV.
                  >
                  > Sounds complicated but Vim should be able to perform all actions with
                  > reasonable speed. The most expensive is f) .
                  >
                  > You should carefully consider when this function should be performed.
                  > I would vote for ; and BufLeave and BufWritePre autocommands.
                  >
                  > m.
                  I write the function like this, but there are some problems.
                  This is my first time to write vim script, so please give me a hand.

                  inoremap <expr> ; UpdateTags()
                  func UpdateTags()
                  "get the file name of the current buffer
                  let currentfilename=bufname("%")
                  "get the last line number in the current buffer
                  let lastline=line('$')
                  let currentfile=getline(1 , lastline)
                  "how to define the temporary file name
                  call writefile(currentfile , ".tmp.cc" , "b")
                  call system('ctags --c++-kinds=+p --fields=+iaS --extra=+q -f .tags
                  .tmp.cc')
                  let currenttags=readfile(".tags" , "b")
                  "remove the comment in the tags file
                  call remove(currenttags , "^!")
                  let alltags=readfile("tags" , "b")
                  call remove(alltags , currentfilename)
                  echo currenttags
                  substitute(currenttags , ".tmp.cc" , currentfilename , "g")
                  "here I want to replace ".tmp.cc" with currentfilename in the new
                  created tags file,
                  "but vim always gives me an error "E486: Pattern not found: currenttags
                  , ".tmp.cc" , currentfilename , "g")"
                  "echo currenttags has showed me currenttags contains ".tmp.cc".
                  call add(alltags , currenttags)
                  call writefile(alltags , "tags" , "b")
                  "I want to write the updated tags into the file "tags" , but failed.
                  "The error is "E730: using List as a String"
                  "I don't understand
                  endfunc

                  Zheng Da
                • Mikolaj Machowski
                  ... Safer:: let fname = expand( %:p ) Full path will prevent ambiguity in some corner cases. ... Just:: let currentfile=getline(1, $ ) ... As I wrote, better
                  Message 8 of 27 , Jan 1, 2007
                  • 0 Attachment
                    On pon sty 1 2007, Mikolaj Machowski wrote:
                    > > Note: much faster, noticeable on big files, would be reading of
                    > > tags file into buffer and just g//d proper lines and add tags at the
                    > > end
                    >
                    > how to read tags into the buffer and what does "g//d proper lines" mean?

                    :new somename
                    :g/\t{filename}\t/d

                    > > - but I hate buffer management in scripts, YMMV.
                    > >
                    > > Sounds complicated but Vim should be able to perform all actions with
                    > > reasonable speed. The most expensive is f) .
                    > >
                    > > You should carefully consider when this function should be performed.
                    > > I would vote for ; and BufLeave and BufWritePre autocommands.
                    > >
                    > > m.
                    >
                    > I write the function like this, but there are some problems.
                    > This is my first time to write vim script, so please give me a hand.
                    >
                    > inoremap <expr> ; UpdateTags()
                    > func UpdateTags()
                    > "get the file name of the current buffer
                    > let currentfilename=bufname("%")

                    Safer::

                    let fname = expand('%:p')

                    Full path will prevent ambiguity in some corner cases.

                    > "get the last line number in the current buffer
                    > let lastline=line('$')
                    > let currentfile=getline(1 , lastline)

                    Just::

                    let currentfile=getline(1, '$')

                    > "how to define the temporary file name
                    > call writefile(currentfile , ".tmp.cc" , "b")
                    > call system('ctags --c++-kinds=+p --fields=+iaS --extra=+q -f .tags
                    > .tmp.cc')
                    > let currenttags=readfile(".tags" , "b")

                    As I wrote, better to skip writing of tags to file, faster and you avoid
                    messing with filenames::

                    let currenttags = system('ctags --c++-kinds=+p -- fields=+iaS
                    --extra=+q -f - .tmp.cc')

                    > "remove the comment in the tags file
                    > call remove(currenttags , "^!")

                    Another benefit of using '-f -' - ctags when dealing with STDOUT doesn't
                    add !comment lines. Note for future - remove() doesn't accept RE, only
                    indexes.

                    > let alltags=readfile("tags" , "b")
                    > call remove(alltags , currentfilename)

                    remove() doesn't accept regexps only indexes. To remove offending lines
                    use filter()::

                    call filter(alltags, "v:val !~ fname")

                    > echo currenttags
                    > substitute(currenttags , ".tmp.cc" , currentfilename , "g")
                    > "here I want to replace ".tmp.cc" with currentfilename in the new
                    > created tags file,
                    > "but vim always gives me an error "E486: Pattern not found: currenttags
                    > , ".tmp.cc" , currentfilename , "g")"

                    ??? substitute() is for strings. Now you can do::

                    let newtags = alltags + currenttags

                    > "echo currenttags has showed me currenttags contains ".tmp.cc".
                    > call add(alltags , currenttags)
                    > call writefile(alltags , "tags" , "b")

                    call writefile(newtags, "tags", 'b')

                    > "I want to write the updated tags into the file "tags" , but failed.
                    > "The error is "E730: using List as a String"
                    > "I don't understand
                    > endfunc
                    >
                    > Zheng Da

                    m.
                  • 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 9 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 10 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 11 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 12 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 13 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 14 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 15 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 16 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 17 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 18 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 19 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 20 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 21 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 22 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 23 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 24 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 25 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 26 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.