码迷,mamicode.com
首页 > 系统相关 > 详细

vim 基础知识

时间:2021-03-15 11:29:06      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:efi   int   cep   call   undefined   which   about   you   ref   

leader

https://vi.stackexchange.com/questions/836/what-is-leader

Vim is full of various commands, which are assigned to almost all keys on the keyboard.
But this causes a problem: Which commands can we use for our own commands,
without interfering with existing ones? And at this moment, the <Leader> key comes into play.
Think about <Leader>-key like a namespace for any user-defined commands.
You can assign any command to a mapping with a leading <Leader> and you can be fully
confident that your mapping won‘t break anything.

By default your <leader> is \, backslash. You can check it with:

:echo mapleader

If this gives you an E121: Undefined variable: mapleader,
it means it‘s set to the default of \. If it gives you something else, then it‘s that ??

You can easily remap it. I mapped it to the space-bar:

:let mapleader = "\<Space>"

Note that the value of mapleader is used at the moment the mapping is defined. So this example:

let mapleader = ","
nnoremap <Leader>a :echo "Hey there ,"<CR>

let mapleader = "\<Space>"
nnoremap <Leader>a :echo "Hey there space"<CR>

Will produce two mappings: ,a and <Space>a.

This means that the current value of mapleader is not necessarily the
value that was used to define your mappings!

In addition, there‘s the maplocalleader, which is the same as mapleader,
except that it‘s used by <LocalLeader> and that it‘s local to the current buffer.

More information about <Leader> can be found in Vim‘s help with :help mapleader.

vim 基础知识

标签:efi   int   cep   call   undefined   which   about   you   ref   

原文地址:https://www.cnblogs.com/Searchor/p/14530353.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!