What is the in a .vimrc file?

后端 未结 5 948
情深已故
情深已故 2020-11-28 17:04

I see in many .vimrc files, and I am wondering what does it mean?

What is it used for?

Just a general overview of

相关标签:
5条回答
  • 2020-11-28 17:26

    The <Leader> key is mapped to \ by default. So if you have a map of <Leader>t, you can execute it by default with \+t. For more detail or re-assigning it using the mapleader variable, see

    :help leader

    To define a mapping which uses the "mapleader" variable, the special string
    "<Leader>" can be used.  It is replaced with the string value of "mapleader".
    If "mapleader" is not set or empty, a backslash is used instead.  
    Example:
        :map <Leader>A  oanother line <Esc>
    Works like:
        :map \A  oanother line <Esc>
    But after:
        :let mapleader = ","
    It works like:
        :map ,A  oanother line <Esc>
    
    Note that the value of "mapleader" is used at the moment the mapping is
    defined.  Changing "mapleader" after that has no effect for already defined
    mappings.
    
    
    
    0 讨论(0)
  • 2020-11-28 17:29

    The "Leader key" is a way of extending the power of VIM's shortcuts by using sequences of keys to perform a command. The default leader key is backslash. Therefore, if you have a map of <Leader>Q, you can perform that action by typing \Q.

    0 讨论(0)
  • 2020-11-28 17:44

    In my system its the \ key. it's used for commands so that you can combine it with other chars.

    0 讨论(0)
  • 2020-11-28 17:45

    Be aware that when you do press your <leader> key you have only 1000ms (by default) to enter the command following it.

    This is exacerbated because there is no visual feedback (by default) that you have pressed your <leader> key and vim is awaiting the command; and so there is also no visual way to know when this time out has happened.

    If you add set showcmd to your vimrc then you will see your <leader> key appear in the bottom right hand corner of vim (to the left of the cursor location) and perhaps more importantly you will see it disappear when the time out happens.

    The length of the timeout can also be set in your vimrc, see :help timeoutlen for more information.

    0 讨论(0)
  • 2020-11-28 17:48

    Vim's <leader> key is a way of creating a namespace for commands you want to define. Vim already maps most keys and combinations of Ctrl + (some key), so <leader>(some key) is where you (or plugins) can add custom behavior.

    For example, if you find yourself frequently deleting exactly 3 words and 7 characters, you might find it convenient to map a command via nmap <leader>d 3dw7x so that pressing the leader key followed by d will delete 3 words and 7 characters. Because it uses the leader key as a prefix, you can be (relatively) assured that you're not stomping on any pre-existing behavior.

    The default key for <leader> is \, but you can use the command :let mapleader = "," to remap it to another key (, in this case).

    Usevim's page on the leader key has more information.

    0 讨论(0)
提交回复
热议问题