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

How to imap a that behaves defferent according conditions?

Expand Messages
  • Yue Wu
    Why I want is, say: If the col( . )-1 is a printable ascii charactor, then does the mapping in insert mode, if not, then will
    Message 1 of 10 , Jan 10, 2009
    • 0 Attachment
      Why I want is, say:

      If the col('.')-1 is a printable ascii charactor, then <space> does the
      mapping
      <C-X><C-u><C-u> in insert mode, if not, then <space> will just insert a
      normal
      space, is it possible?

      --
      Regards,
      Van.

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • StarWing
      you can try supertab.vim http://www.vim.org/scripts/script.php?script_id=1643 ... --~--~---------~--~----~------------~-------~--~----~ You received this
      Message 2 of 10 , Jan 10, 2009
      • 0 Attachment
        you can try supertab.vim
        http://www.vim.org/scripts/script.php?script_id=1643

        On 1月11日, 上午7时24分, "Yue Wu" <vano...@...> wrote:
        > Why I want is, say:
        >
        > If the col('.')-1 is a printable ascii charactor, then <space> does the
        > mapping
        > <C-X><C-u><C-u> in insert mode, if not, then <space> will just insert a
        > normal
        > space, is it possible?http://www.vim.org/scripts/script.php?script_id=1643
        >
        > --
        > Regards,
        > Van.
        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Yue Wu
        ... Thanks for advice, but a simple solution like a function with several lines is better, and supertab is just for tab, right? ... -- Regards, Van.
        Message 3 of 10 , Jan 10, 2009
        • 0 Attachment
          On Sun, 11 Jan 2009 08:32:08 +0800, StarWing <weasley_wx@...> wrote:

          >
          > you can try supertab.vim
          > http://www.vim.org/scripts/script.php?script_id=1643

          Thanks for advice, but a simple solution like a function with several
          lines is better,
          and supertab is just for tab, right?

          >
          > On 1月11日, 上午7时24分, "Yue Wu" <vano...@...> wrote:
          >> Why I want is, say:
          >>
          >> If the col('.')-1 is a printable ascii charactor, then <space> does the
          >> mapping
          >> <C-X><C-u><C-u> in insert mode, if not, then <space> will just insert a
          >> normal
          >> space, is it
          >> possible?http://www.vim.org/scripts/script.php?script_id=1643
          >>
          >> --
          >> Regards,
          >> Van.
          > >



          --
          Regards,
          Van.

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • StarWing
          just a problem, in your words, app| | places the location of cursor, now you press , and it spead to , but can t find match.then you
          Message 4 of 10 , Jan 10, 2009
          • 0 Attachment
            just a problem, in your words,
            app|
            "|" places the location of cursor, now you press <space>, and it spead
            to <C-X><C-U><C-U>, but can't find match.then you will find, you can't
            input space in this place.
            you can have a try.

            On 1月11日, 上午8时35分, "Yue Wu" <vano...@...> wrote:
            > On Sun, 11 Jan 2009 08:32:08 +0800, StarWing <weasley...@...> wrote:
            >
            > > you can try supertab.vim
            > >http://www.vim.org/scripts/script.php?script_id=1643
            >
            > Thanks for advice, but a simple solution like a function with several
            > lines is better,
            > and supertab is just for tab, right?
            >
            >
            >
            > > On 1月11日, 上午7时24分, "Yue Wu" <vano...@...> wrote:
            > >> Why I want is, say:
            >
            > >> If the col('.')-1 is a printable ascii charactor, then <space> does the
            > >> mapping
            > >> <C-X><C-u><C-u> in insert mode, if not, then <space> will just insert a
            > >> normal
            > >> space, is it
            > >> possible?http://www.vim.org/scripts/script.php?script_id=1643
            >
            > >> --
            > >> Regards,
            > >> Van.
            >
            > --
            > Regards,
            > Van.
            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Yue Wu
            ... Yes, that s the correct respond of vim. That s not a problem for me. I just want that: In condition app| , will do for me,
            Message 5 of 10 , Jan 10, 2009
            • 0 Attachment
              On Sun, 11 Jan 2009 09:10:12 +0800, StarWing <weasley_wx@...> wrote:

              >
              > just a problem, in your words,
              > app|
              > "|" places the location of cursor, now you press <space>, and it spead
              > to <C-X><C-U><C-U>, but can't find match.then you will find, you can't
              > input space in this place.
              > you can have a try.
              >

              Yes, that's the correct respond of vim. That's not a problem for me.
              I just want that:

              In condition "app|<space>", <space> will do <C-x><C-u><C-u> for me,
              say there is a completion "程“ for app, result will be "程|"

              In condition "程|<space>", <space> will insert a <space> for me,
              so result will be "程 |"

              Any easy solution?

              --
              Regards,
              Van.

              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_use" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • StarWing
              sorry for my lazy, i use chinese to explain it... ºÃ°É£¬ÄãÓ¦¸Ã¿ÉÒÔÕâô×ö£º function! Space() if getline( . )[col( . )-2] !~ a
              Message 6 of 10 , Jan 10, 2009
              • 0 Attachment
                sorry for my lazy, i use chinese to explain it...
                好吧,你应该可以这么做:

                function! Space()
                if getline('.')[col('.')-2] !~ '\a'
                " 加入下面这一行,防止变成继续补全,见:h ctrl-x_ctrl-n
                \ || pumvisible()
                return ' '
                else
                let g:old_col = col('.')
                return "\<c-x>\<c-n>"
                endif
                endfunction

                function! ResultOfSpace()
                " 如果出现列表,自动选中第一个
                if pumvisible()
                return "\<c-n>"

                " 如果当前只有唯一匹配,返回如下字符串,防止再次按空格键时产生连续补全
                elseif col('.') != g:old_col
                return " \<bs>"

                " 补全失败,补上一个空格
                else
                return " "
                endif
                endfunction

                ino <space> <c-r>=Space()<cr><c-r>=ResultOfSpace()<cr>

                On 1月11日, 上午9时18分, "Yue Wu" <vano...@...> wrote:
                > On Sun, 11 Jan 2009 09:10:12 +0800, StarWing <weasley...@...> wrote:
                >
                > > just a problem, in your words,
                > > app|
                > > "|" places the location of cursor, now you press <space>, and it spead
                > > to <C-X><C-U><C-U>, but can't find match.then you will find, you can't
                > > input space in this place.
                > > you can have a try.
                >
                > Yes, that's the correct respond of vim. That's not a problem for me.
                > I just want that:
                >
                > In condition "app|<space>", <space> will do <C-x><C-u><C-u> for me,
                > say there is a completion "程“ for app, result will be "程|"
                >
                > In condition "程|<space>", <space> will insert a <space> for me,
                > so result will be "程 |"
                >
                > Any easy solution?
                >
                > --
                > Regards,
                > Van.
                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_use" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              • StarWing
                sorry for my lazy, i use chinese to explain it... ºÃ°É£¬ÄãÓ¦¸Ã¿ÉÒÔÕâô×ö£º function! Space() if getline( . )[col( . )-2] !~ a
                Message 7 of 10 , Jan 10, 2009
                • 0 Attachment
                  sorry for my lazy, i use chinese to explain it...
                  好吧,你应该可以这么做:

                  function! Space()
                  if getline('.')[col('.')-2] !~ '\a'
                  " 加入下面这一行,防止变成继续补全,见:h ctrl-x_ctrl-n
                  \ || pumvisible()
                  return ' '
                  else
                  let g:old_col = col('.')
                  return "\<c-x>\<c-n>"
                  endif
                  endfunction

                  function! ResultOfSpace()
                  " 如果出现列表,自动选中第一个
                  if pumvisible()
                  return "\<c-n>"

                  " 如果当前只有唯一匹配,返回如下字符串,防止再次按空格键时产生连续补全
                  elseif col('.') != g:old_col
                  return " \<bs>"

                  " 补全失败,补上一个空格
                  else
                  return " "
                  endif
                  endfunction

                  ino <space> <c-r>=Space()<cr><c-r>=ResultOfSpace()<cr>

                  On 1月11日, 上午9时18分, "Yue Wu" <vano...@...> wrote:
                  > On Sun, 11 Jan 2009 09:10:12 +0800, StarWing <weasley...@...> wrote:
                  >
                  > > just a problem, in your words,
                  > > app|
                  > > "|" places the location of cursor, now you press <space>, and it spead
                  > > to <C-X><C-U><C-U>, but can't find match.then you will find, you can't
                  > > input space in this place.
                  > > you can have a try.
                  >
                  > Yes, that's the correct respond of vim. That's not a problem for me.
                  > I just want that:
                  >
                  > In condition "app|<space>", <space> will do <C-x><C-u><C-u> for me,
                  > say there is a completion "程“ for app, result will be "程|"
                  >
                  > In condition "程|<space>", <space> will insert a <space> for me,
                  > so result will be "程 |"
                  >
                  > Any easy solution?
                  >
                  > --
                  > Regards,
                  > Van.
                  --~--~---------~--~----~------------~-------~--~----~
                  You received this message from the "vim_use" maillist.
                  For more information, visit http://www.vim.org/maillist.php
                  -~----------~----~----~----~------~----~------~--~---
                • Yue Wu
                  It works fine, thank you!为什么你的每封信都发了相同的两份?小心被骂。。。On Sun, 11 Jan 2009 15:35:53 +0800, StarWing wrote:
                  Message 8 of 10 , Jan 11, 2009
                  • 0 Attachment
                    It works fine, thank you!

                    为什么你的每封信都发了相同的两份?小心被骂。。。

                    On Sun, 11 Jan 2009 15:35:53 +0800, StarWing wrote:

                    >
                    > sorry for my lazy, i use chinese to explain it...
                    > 好吧,你应该可以这么做:
                    >
                    > function! Space()
                    > if getline('.')[col('.')-2] !~ '\a'
                    > " 加入下面这一行,防止变成继续补全,见:h ctrl-x_ctrl-n
                    > \ || pumvisible()
                    > return ' '
                    > else
                    > let g:old_col = col('.')
                    > return "\<c-x>\<c-n>"
                    > endif
                    > endfunction
                    >
                    > function! ResultOfSpace()
                    > " 如果出现列表,自动选中第一个
                    > if pumvisible()
                    > return "\<c-n>"
                    >
                    > "
                    > 如果当前只有唯一匹配,返回如下字符串,防止再次按空格键时产生连续补全
                    > elseif col('.') != g:old_col
                    > return " \<bs>"
                    >
                    > " 补全失败,补上一个空格
                    > else
                    > return " "
                    > endif
                    > endfunction
                    >
                    > ino <space> <c-r>=Space()<cr><c-r>=ResultOfSpace()<cr>
                    >
                    > On 1月11日, 上午9时18分, "Yue Wu" <vano...@...> wrote:
                    >> On Sun, 11 Jan 2009 09:10:12 +0800, StarWing <weasley...@...>
                    >> wrote:
                    >>
                    >> > just a problem, in your words,
                    >> > app|
                    >> > "|" places the location of cursor, now you press <space>, and it spead
                    >> > to <C-X><C-U><C-U>, but can't find match.then you will find, you can't
                    >> > input space in this place.
                    >> > you can have a try.
                    >>
                    >> Yes, that's the correct respond of vim. That's not a problem for me.
                    >> I just want that:
                    >>
                    >> In condition "app|<space>", <space> will do <C-x><C-u><C-u> for me,
                    >> say there is a completion "程“ for app, result will be "程|"
                    >>
                    >> In condition "程|<space>", <space> will insert a <space> for me,
                    >> so result will be "程 |"
                    >>
                    >> Any easy solution?
                    >>
                    >> --
                    >> Regards,
                    >> Van.
                    > >



                    --
                    Regards,
                    Van.

                    --~--~---------~--~----~------------~-------~--~----~
                    You received this message from the "vim_use" maillist.
                    For more information, visit http://www.vim.org/maillist.php
                    -~----------~----~----~----~------~----~------~--~---
                  • StarWing
                    ¶÷......Äã°Ñ ¸Ä³É ÊÔÊÔ¿´£¬ÆäËûµÄ¿ÉÒÔ²»±ä......ÎÒÊÇÓÃc-n×ö²âÊԵģ¬ÒòΪÎÒµÄvimÎļþ�
                    Message 9 of 10 , Jan 11, 2009
                    • 0 Attachment
                      恩......你把<c-x><c-n>改成<c-x><c-u>试试看,其他的可以不变......我是用c-n做测试的,因为我的vim文件类型没有
                      completefunc,没法试验c-u。
                      我也不知道啊,我用火狐浏览器,不知道是不是Bug......

                      by the way, we speak chinese here, may be not good...

                      On 1月11日, 下午4时15分, "Yue Wu" <vano...@...> wrote:
                      > It works fine, thank you!
                      >
                      > 为什么你的每封信都发了相同的两份?小心被骂。。。
                      >
                      >
                      >
                      > On Sun, 11 Jan 2009 15:35:53 +0800, StarWing wrote:
                      >
                      > > sorry for my lazy, i use chinese to explain it...
                      > > 好吧,你应该可以这么做:
                      >
                      > > function! Space()
                      > > if getline('.')[col('.')-2] !~ '\a'
                      > > " 加入下面这一行,防止变成继续补全,见:h ctrl-x_ctrl-n
                      > > \ || pumvisible()
                      > > return ' '
                      > > else
                      > > let g:old_col = col('.')
                      > > return "\<c-x>\<c-n>"
                      > > endif
                      > > endfunction
                      >
                      > > function! ResultOfSpace()
                      > > " 如果出现列表,自动选中第一个
                      > > if pumvisible()
                      > > return "\<c-n>"
                      >
                      > > "
                      > > 如果当前只有唯一匹配,返回如下字符串,防止再次按空格键时产生连续补全
                      > > elseif col('.') != g:old_col
                      > > return " \<bs>"
                      >
                      > > " 补全失败,补上一个空格
                      > > else
                      > > return " "
                      > > endif
                      > > endfunction
                      >
                      > > ino <space> <c-r>=Space()<cr><c-r>=ResultOfSpace()<cr>
                      >
                      > > On 1月11日, 上午9时18分, "Yue Wu" <vano...@...> wrote:
                      > >> On Sun, 11 Jan 2009 09:10:12 +0800, StarWing <weasley...@...>
                      > >> wrote:
                      >
                      > >> > just a problem, in your words,
                      > >> > app|
                      > >> > "|" places the location of cursor, now you press <space>, and it spead
                      > >> > to <C-X><C-U><C-U>, but can't find match.then you will find, you can't
                      > >> > input space in this place.
                      > >> > you can have a try.
                      >
                      > >> Yes, that's the correct respond of vim. That's not a problem for me.
                      > >> I just want that:
                      >
                      > >> In condition "app|<space>", <space> will do <C-x><C-u><C-u> for me,
                      > >> say there is a completion "程" for app, result will be "程|"
                      >
                      > >> In condition "程|<space>", <space> will insert a <space> for me,
                      > >> so result will be "程 |"
                      >
                      > >> Any easy solution?
                      >
                      > >> --
                      > >> Regards,
                      > >> Van.
                      >
                      > --
                      > Regards,
                      > Van.
                      --~--~---------~--~----~------------~-------~--~----~
                      You received this message from the "vim_use" maillist.
                      For more information, visit http://www.vim.org/maillist.php
                      -~----------~----~----~----~------~----~------~--~---
                    • Tony Mechelynck
                      On 11/01/09 10:06, StarWing wrote: [...] ... [...] Well, there are pros and cons: The advantage is of course that, if you both speak Chinese natively, you run
                      Message 10 of 10 , Jan 11, 2009
                      • 0 Attachment
                        On 11/01/09 10:06, StarWing wrote:
                        [...]
                        > by the way, we speak chinese here, may be not good...
                        [...]

                        Well, there are pros and cons:

                        The advantage is of course that, if you both speak Chinese natively, you
                        run less risk of misunderstanding one another due to bad mastery of the
                        language.

                        The disadvantage, also "of course", is that you shut off from
                        participation anyone who doesn't understand Chinese.

                        Now it happens that, for good or bad, the vehicular language of this
                        mailing list is English. This doesn't necessarily mean that even a
                        majority of participants are native English speakers: Bram is a
                        Dutchman, there are several prominent French-speakers, quite a number of
                        Chinese, some Russians and at least one regular Spaniard, to name only a
                        few. To be sure, there are some British and Usonian people here too,
                        including several quite prominent members of this group, but I'm not
                        sure they are the majority. All that "vehicular language" means is that
                        all posters are expected to understand what is said in English, and to
                        be able to make themselves understood in something resembling English
                        (even broken English, but of course, the more broken, the less
                        understandable it will be). With the help of a dictionary and/or grammar
                        if necessary.


                        Best regards,
                        Tony.
                        --
                        ARTHUR: A scratch? Your arm's off!
                        BLACK KNIGHT: No, it isn't.
                        ARTHUR: Well, what's that then?
                        BLACK KNIGHT: I've had worse.
                        The Quest for the Holy Grail (Monty
                        Python)

                        --~--~---------~--~----~------------~-------~--~----~
                        You received this message from the "vim_use" maillist.
                        For more information, visit http://www.vim.org/maillist.php
                        -~----------~----~----~----~------~----~------~--~---
                      Your message has been successfully submitted and would be delivered to recipients shortly.