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

Re: how to map ctrl-t?

Expand Messages
  • Tim Chase
    ... As described in ... you can use map something (literally with the less-than see dash tee greater-than ) in your vimrc file to get the control+T
    Message 1 of 9 , Mar 4, 2008
      > Interactively I can type the command
      >
      > :map ^t something
      >
      > (where ^t is control-t) and it works fine.
      >
      > But I'm trying to edit my vimrc file to put the map command in there,
      > and I can't do it because I can't type control-t and have it go into
      > the file. How can I do this? Thanks.


      As described in

      :help key-notation

      you can use

      map <c-t> something

      (literally with the "less-than see dash tee greater-than") in
      your vimrc file to get the control+T mapping. I actually prefer
      this as it doesn't actually stick the control+T in the file
      (which can screw up some other text-editors that don't know how
      to deal with it reliably).

      -tim



      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Charles E Campbell Jr
      ... map :echo this works! Regards, Chip Campbell --~--~---------~--~----~------------~-------~--~----~ You received this message from the vim_use
      Message 2 of 9 , Mar 4, 2008
        mitch wrote:
        > Interactively I can type the command
        >
        > :map ^t something
        >
        > (where ^t is control-t) and it works fine.
        >
        > But I'm trying to edit my vimrc file to put the map command in there,
        > and I can't do it because I can't type control-t and have it go into
        > the file. How can I do this? Thanks.
        >

        map <c-t> :echo "this works!"<cr>

        Regards,
        Chip Campbell


        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Benjamin Fritz
        ... But note, CTRL-T is already defined, to jump back after jumping to a tag. This is especially useful when navigating help files! When you see a link, type
        Message 3 of 9 , Mar 4, 2008
          On 3/4/08, Charles E Campbell Jr <drchip@...> wrote:
          >
          > mitch wrote:
          > > Interactively I can type the command
          > >
          > > :map ^t something
          > >
          > > (where ^t is control-t) and it works fine.
          > >
          > > But I'm trying to edit my vimrc file to put the map command in there,
          > > and I can't do it because I can't type control-t and have it go into
          > > the file. How can I do this? Thanks.
          > >
          >
          > map <c-t> :echo "this works!"<cr>
          >
          > Regards,
          > Chip Campbell
          >
          >

          But note, CTRL-T is already defined, to jump back after jumping to a
          tag. This is especially useful when navigating help files! When you
          see a link, type CTRL-] to jump to it, and then CTRL-T to jump back.
          If you do remap CTRL-T, be sure to remap the existing functionality to
          something as well!

          Also, consider :noremap (or :nnoremap, :inoremap, etc.) instead of
          :map, to avoid potential recursive mappings and other unexpected
          behavior.

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Benjamin Fritz
          ... Oh, and another note. Although using the style as Chip suggest is the proper way to get a CTRL-T in this case, in the general case you can use CTRL-V
          Message 4 of 9 , Mar 4, 2008
            On 3/4/08, Benjamin Fritz <fritzophrenic@...> wrote:
            > On 3/4/08, Charles E Campbell Jr <drchip@...> wrote:
            > >
            > > mitch wrote:
            > > > Interactively I can type the command
            > > >
            > > > :map ^t something
            > > >
            > > > (where ^t is control-t) and it works fine.
            > > >
            > > > But I'm trying to edit my vimrc file to put the map command in there,
            > > > and I can't do it because I can't type control-t and have it go into
            > > > the file. How can I do this? Thanks.
            > > >
            > >
            > > map <c-t> :echo "this works!"<cr>
            > >
            > > Regards,
            > > Chip Campbell
            > >
            > >
            >
            >
            > But note, CTRL-T is already defined, to jump back after jumping to a
            > tag. This is especially useful when navigating help files! When you
            > see a link, type CTRL-] to jump to it, and then CTRL-T to jump back.
            > If you do remap CTRL-T, be sure to remap the existing functionality to
            > something as well!
            >
            > Also, consider :noremap (or :nnoremap, :inoremap, etc.) instead of
            > :map, to avoid potential recursive mappings and other unexpected
            > behavior.
            >

            Oh, and another note. Although using the <C-T> style as Chip suggest
            is the proper way to get a CTRL-T in this case, in the general case
            you can use CTRL-V CTRL-T in insert mode to get the literal ^t
            character. If you're on a Windows system, CTRL-V is probably remapped
            to CTRL-Q, so use that in its place.

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • mitch
            Thanks! I m used to browsers and other editors where ^t opens a new tab, and I had never used ^t in vim before, so I m going to go with the mapping map ^T
            Message 5 of 9 , Mar 4, 2008
              Thanks!

              I'm used to browsers and other editors where ^t opens a new tab, and I
              had never used ^t in vim before, so I'm going to go with the mapping

              map ^T :tabnew^M


              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_use" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • Benjamin Fritz
              ... Consider instead: noremap :tabnew noremap The first mapping will do exactly the same thing as yours, except it won t work in insert or
              Message 6 of 9 , Mar 4, 2008
                On 3/4/08, mitch <mgart@...> wrote:
                >
                > Thanks!
                >
                > I'm used to browsers and other editors where ^t opens a new tab, and I
                > had never used ^t in vim before, so I'm going to go with the mapping
                >
                > map ^T :tabnew^M
                >
                >
                >

                Consider instead:

                noremap <C-T> :tabnew<CR>
                noremap <BS> <C-T>

                The first mapping will do exactly the same thing as yours, except it
                won't work in insert or visual modes (use inoremap and vnoremap,
                respectively, if you desire this behavior). It uses <C-T> and <CR>
                rather than the literal characters, however, for better compatibility
                with other terminals, systems, copy-paste, etc.

                The second mapping will remap the backspace key to the built-in
                functionality of CTRL-T. Note the use of noremap will use the unmapped
                behavior of the right-hand-side of the mapping. I use backspace in
                this mapping to emulate another common browser shortcut, which was
                your inspiration for your CTRL-T mapping. Since this is a normal-mode
                only mapping, you can continue using backspace normally in insert
                mode, etc. to delete characters.

                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_use" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              • Charles E Campbell Jr
                ... Well, as soon as you want to ask: how can I just jump to where this variable (or function, etc) is defined (answer: see :help tags), you ll find yourself
                Message 7 of 9 , Mar 4, 2008
                  mitch wrote:
                  > Thanks!
                  >
                  > I'm used to browsers and other editors where ^t opens a new tab, and I
                  > had never used ^t in vim before, so I'm going to go with the mapping
                  >
                  > map ^T :tabnew^M
                  >
                  Well, as soon as you want to ask: how can I just jump to where this
                  variable (or function, etc) is defined (answer: see :help tags), you'll
                  find yourself using ctrl-]. Then you'll want to ask: how do I get
                  back? But you will have given yourself a nice bad habit...

                  Regards,
                  Chip Campbell


                  --~--~---------~--~----~------------~-------~--~----~
                  You received this message from the "vim_use" maillist.
                  For more information, visit http://www.vim.org/maillist.php
                  -~----------~----~----~----~------~----~------~--~---
                • Tony Mechelynck
                  ... You can get back using Ctrl-O, which is mentioned together with Ctrl-T under :help bars . It uses the jumplist, and has the advantage that it has a
                  Message 8 of 9 , Mar 4, 2008
                    Charles E Campbell Jr wrote:
                    > mitch wrote:
                    >> Thanks!
                    >>
                    >> I'm used to browsers and other editors where ^t opens a new tab, and I
                    >> had never used ^t in vim before, so I'm going to go with the mapping
                    >>
                    >> map ^T :tabnew^M
                    >>
                    > Well, as soon as you want to ask: how can I just jump to where this
                    > variable (or function, etc) is defined (answer: see :help tags), you'll
                    > find yourself using ctrl-]. Then you'll want to ask: how do I get
                    > back? But you will have given yourself a nice bad habit...
                    >
                    > Regards,
                    > Chip Campbell

                    You can get back using Ctrl-O, which is mentioned together with Ctrl-T
                    under ":help bars". It uses the jumplist, and has the advantage that it
                    has a converse command placed right next to it on an AZERTY or QWERTY
                    keyboard: Ctrl-I (go forward after going back).

                    Best regards,
                    Tony.
                    --
                    Christian, n.:
                    One who believes that the New Testament is a divinely inspired
                    book admirably suited to the spiritual needs of his neighbor. One who
                    follows the teachings of Christ in so far as they are not inconsistent
                    with a life of sin.

                    --~--~---------~--~----~------------~-------~--~----~
                    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.