Hot answers tagged

11

[count] is optional. If given, the mapping works for count lines (ie. comments out count lines). <Leader> is usually the backslash key (\), although this can be remapped (also see What is <Leader>? and How can I find out what <Leader> is set to? And is it possible to remap &ltLeader>?) cc is exactly that: two c's. NERDComComment has nothing ...


7

You should use this: let maplocalleader="\<space>" Note that the mapping is the same for the reguler leader let mapleader="\<Space>"


4

In the .vimrc, there is no difference between them. Without an explicit scope, vim chooses between g: and l: depending on the context. l: is implicit within functions, g: is implicit everywhere else.


3

When you register it this way, your new autocommand will be triggered after all other autocommands registered on the same event, in particular after the one that sources your ftplugin -- I suppose you define the mapping in an ftplugin (*). You could change that, probably by changing the order between this line and the :filetype xxxx in your .vimrc, but this ...


3

If you simply need to create this mapping: nnoremap <leader>, , nnoremap <leader>; ; OP mentions <leader> is comma, via let mapleader = ',' or similar.


3

You can use the mapcheck() function to check if the user mapped a key to something: :echo json_encode(mapcheck('<F1>', 'n')) "" :echo mapcheck('<F11>', 'n') :set cursorcolumn!<CR>:set cursorcolumn?<CR> So in your mapping, you can do: if !hasmapto('<Plug>MyFunction', 'n') && mapcheck('<Leader>f', 'n') is# '' ...


2

The command is used in normal mode by typing first a count, like 10, followed by the <Leader> key (default is \) and finally cc. Example; type 10\cc in normal mode to comment out 10 lines starting at the cursor position. Omit the count to only comment out the current line. Many people like to remap the <Leader> key to ,. More info here: http://...


2

No. The keys Ctrl, Shift and Alt are modifier keys. They modify another key, when pressed together with it. Vim can't detect them by itself.


1

A couple of points: (Most) maps of this form that I have seen want to be run in normal mode. So you need to press your leader key followed by tn, without any colons. Dont use regular map. It does too much, and is too easy to break. Prefer in this case a noremap variant nnoremap (for normal mode mappings). Your command fails because vim runs the command ...


1

silent! {map} <unique> {lhs} {rhs} Works too. The <unique> modifier issues an error if there is already a mapping for the left-hand side, which silent swallows.


1

You may do nnoremap <leader><leader> G. Then just type the linenumber and double click the leaderkey.


1

You can simply use substitute(): substitute(get(g:,"mapleader","\\"), ' ', '<Space>', '') Since there is only one case where get(g:,"mapleader","\\") will return a single whitespace this should work.


1

To set your leader key, you must use let mapleader = "," not let g:mapleader = ",". From :h <leader> *<Leader>* *mapleader* 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 ...


1

You can use: let mapleader = " " let maplocalleader = " "


Only top voted, non community-wiki answers of a minimum length are eligible