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

Re: What plugin would do this?

Expand Messages
  • Tom Link
    ... If you re willing to give up the ctrl-n/p requirement, this page could be of interest: http://vim.wikia.com/wiki/Category:Automated_Text_Insertion -- You
    Message 1 of 8 , Apr 1, 2010
    • 0 Attachment
      > I'd have a about a hundred of those if I could use a popup menu, ala
      > completion ctrl-n/p, just a alphebetized list.

      If you're willing to give up the ctrl-n/p requirement, this page could
      be of interest:
      http://vim.wikia.com/wiki/Category:Automated_Text_Insertion

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

      To unsubscribe, reply using "remove me" as the subject.
    • caruso_g
      ... I use XPTemplate for that: http://www.vim.org/scripts/script.php?script_id=2611 You can create your own snippets that will not be overridden by plugin
      Message 2 of 8 , Apr 2, 2010
      • 0 Attachment
        > I'm positive some of you already do this, and I wanna too ;) so bear
        > with me.
        > I map some F-keys with stuff like
        > :imap <f2> for(i=0;i ;i++)
        > :imap <f3> vector< >::iterator it =  xxx.begin(), end =  xxx.end()
        > :imap <f4> while (my ($k,$v) = each %
        > I'd have a about a hundred of those if I could use a popup menu, ala
        > completion ctrl-n/p, just a alphebetized list.
        > How can I do that?

        I use XPTemplate for that: http://www.vim.org/scripts/script.php?script_id=2611
        You can create your own snippets that will not be overridden by plugin
        updates.
        All snippets with the same abbreviation will show a pop up menu to
        choose from ala ctrl-n/p
        You will also be able to set "tab" stops ala TextMate, multiple
        portion of the snippet and a lot of other interesting features.

        I hope this help.

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

        To unsubscribe, reply using "remove me" as the subject.
      • vfantasie
        I think what you need is a code snippets plugin. There re at least 4-5 plugins that can do that. You can search these plugin names in vim.org XPTemplate,
        Message 3 of 8 , Apr 2, 2010
        • 0 Attachment
          I think what you need is a code snippets plugin.
          There're at least 4-5 plugins that can do that.

          You can search these plugin names in vim.org
          XPTemplate, Snipmate, UltiSnips, Codecomplete, snippetsEmu

          UltiSnips need python, I didn't tried it.
          My favourite is Snipmate, because I think its snippet's syntax is the
          most elegant one.

          On 4月2日, 上午9时51分, MK <halfcountp...@...> wrote:
          > I'm positive some of you already do this, and I wanna too ;) so bear
          > with me.
          >
          > I map some F-keys with stuff like
          >
          > :imap <f2> for(i=0;i ;i++)
          > :imap <f3> vector< >::iterator it = xxx.begin(), end = xxx.end()
          > :imap <f4> while (my ($k,$v) = each %
          >
          > I'd have a about a hundred of those if I could use a popup menu, ala
          > completion ctrl-n/p, just a alphebetized list.
          >
          > How can I do that?
          >
          > --
          > MK <halfcountp...@...>

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

          To unsubscribe, reply using "remove me" as the subject.
        • Christian Brabandt
          Hi MK! ... I don t know if there is a plugin that does this kind of stuff. I would do it like this: ,----[ template.vim ]- ... `---- Define your template stuff
          Message 4 of 8 , Apr 2, 2010
          • 0 Attachment
            Hi MK!

            On Do, 01 Apr 2010, MK wrote:

            > I'm positive some of you already do this, and I wanna too ;) so bear
            > with me.
            >
            > I map some F-keys with stuff like
            >
            > :imap <f2> for(i=0;i ;i++)
            > :imap <f3> vector< >::iterator it = xxx.begin(), end = xxx.end()
            > :imap <f4> while (my ($k,$v) = each %
            >
            > I'd have a about a hundred of those if I could use a popup menu, ala
            > completion ctrl-n/p, just a alphebetized list.

            I don't know if there is a plugin that does this kind of stuff. I would
            do it like this:

            ,----[ template.vim ]-
            | let s:template = [
            | \ 'for(i=0;i ;i++)',
            | \ 'vector< >::iterator it = xxx.begin(), end = xxx.end()',
            | \ 'while (my ($k,$v) = each %'
            | \ ]
            |
            | fun! CompleteTemplate(findstart, base)
            | if a:findstart
            | " locate the start of the word
            | let line = getline('.')
            | let start = col('.') - 1
            | while start > 0 && line[start - 1] =~ '\a'
            | let start -= 1
            | endwhile
            | return start
            | else
            | let res = []
            | for item in s:template
            | if item =~# '^' . a:base
            | call add(res, item)
            | endif
            | endfor
            | return res
            | endif
            | endfun
            | set completefunc=CompleteTemplate
            `----

            Define your template stuff in the variable s:template
            Each line has to begin with a \ and end with a comma (except the last
            line) and each template needs to be put in quotes. Linebreaks are
            trickier though. I am not sure right now, how to insert a linebreak. For
            a tab, you could use \t in double quotation marks.

            Source this file (or if you'd like to have this as a plugin, put it in
            your ~/.vim/plugin directory if you are on Unix or $VIM and for Windows
            put it in your $HOME/vimfiles/plugin directory (and create directories
            that do not exist yet). The restart vim and this file should always be
            loaded if your .vimrc contains the line
            :filetype plugin on

            Then you can use <ctrl-x><ctrl-u> to complete your code. All matching
            templates will be put on a completion menu.

            regards,
            Christian

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

            To unsubscribe, reply using "remove me" as the subject.
          • Marc Weber
            ... If you go the snipmate way try installing snipmate using vim-addon-manager because you ll get my patched version then. You can prevent tlib plugins from
            Message 5 of 8 , Apr 2, 2010
            • 0 Attachment
              Excerpts from vfantasie's message of Fri Apr 02 10:41:02 +0200 2010:
              > I think what you need is a code snippets plugin.

              If you go the snipmate way try installing snipmate using
              vim-addon-manager because you'll get my patched version then.

              You can prevent tlib plugins from loading this way:
              let loaded_cmdlinehelp=1
              But most tlib plugins are very nice. If you don't know them yet you
              should have a look at them.

              May patched version of snipmate provides a new command:
              SnipMateOpenSnippetFiles which will help you open your snippets files
              faster and add well indented snippets easier. Eg you don't care about
              inedntation. You just select your code in a snippets file visually and
              press <cr> to replace spaces by tabs.

              Also when adding a new snippets you don't have to reload snippets.
              Snippets are loaded lazily. So snippets are updated whenever you
              write the snippets file. Those features provide much value to me.

              Marc Weber

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

              To unsubscribe, reply using "remove me" as the subject.
            • MK
              On Thu, 1 Apr 2010 21:51:49 -0400 MK wrote: Thanks for the suggestions gang. I ended up discovering you can create your own
              Message 6 of 8 , Apr 6, 2010
              • 0 Attachment
                On Thu, 1 Apr 2010 21:51:49 -0400
                MK <halfcountplus@...> wrote:

                Thanks for the suggestions gang. I ended up discovering you can create
                your own dictionary for the completion pop-up menu, so I just removed
                ctags & omincppcomplete entirely to reduce clutter and set
                complete=.,k,b

                . is for matches in this buffer
                k is for the dictionary file (set with dictionary+=/path/to/textfile)
                b is for matches in other buffers

                Then I added a bunch of :iab abbreviations (thanks Sven) which work
                great, and since SnipMate seems truly neat, installed it too. Hopefully
                soon I will be able to program without doing any typing at all ;)

                --
                MK <halfcountplus@...>

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

                To unsubscribe, reply using "remove me" as the subject.
              Your message has been successfully submitted and would be delivered to recipients shortly.