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

Aliases in .vimrc?

Expand Messages
  • Rick Hogg
    Hello, Just wondering if there s a way to make permanent aliases/shortcuts for Vim. For example, I have some documents with improper line breaks with lots of
    Message 1 of 2 , Jul 31, 2006
    • 0 Attachment
      Hello,
      Just wondering if there's a way to make permanent aliases/shortcuts for Vim. For example, I have some documents with improper line breaks with lots of ^M's. The command to correct this is :%s/\r/\r/g so I'm wondering if there's a way to name this action "sub" so all I have to type is :sub to run this. Is this a .vimrc thing?

      Thanks


      ---------------------------------
      How low will we go? Check out Yahoo! Messenger’s low PC-to-Phone call rates.
    • Adam Wolff
      You can define a map, which mimics user input. You can define the modes in which a map is active. For instance, to make it so that pressing in normal
      Message 2 of 2 , Aug 1, 2006
      • 0 Attachment
        You can define a map, which mimics user input. You can define the
        modes in which a map is active. For instance, to make it so that
        pressing <C-M> in normal mode does your line end replacement, you
        could add this to your vimrc:
        nmap <C-e> :%s/\r/\r/g <CR>

        You can find out more by typing
        :help map

        Also, you can define commands as you suggest below, so that typing at
        the command line runs a command (as you suggest below)
        command Sub :%s/\r/\r/g

        User defined commands conventionally start with a capital letter.

        :help command

        On 7/31/06, Rick Hogg <eulipion2@...> wrote:
        > Hello,
        > Just wondering if there's a way to make permanent aliases/shortcuts for Vim. For example, I have some documents with improper line breaks with lots of ^M's. The command to correct this is :%s/\r/\r/g so I'm wondering if there's a way to name this action "sub" so all I have to type is :sub to run this. Is this a .vimrc thing?
        >
        > Thanks
        >
        >
        > ---------------------------------
        > How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call rates.
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.