Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

New answers tagged

2

| is used to separate a map command from the next one, you need to escape it or use <bar> instead, read :h map-bar for further detail. Your map is unnecessarily complicated, {rhs} of a map without :h :map-<expr> is applied as typed, no need to use execute and normal in this case: nnoremap <Leader>h /\(A\<bar>B\)<cr>


0

This is a bit of a guess, but I suspect it has to with | also being the ex command separator. So execute probably mangles things, and needs to see \|, which in string form would \\\|—in other words, | needs to be escaped. Alternative ideas: :/ is an ex command that addresses the search pattern entered. If memory serves, it works rather like a normal / You ...


3

Due to the way that the keyboard input is handled internally, this unfortunately isn't generally possible today, even in GVIM. Some key combinations, like Ctrl + non-alphabetic cannot be mapped, and Ctrl + letter vs. Ctrl + Shift + letter cannot be distinguished. (Unless your terminal sends a distinct termcap code for it, which most don't.) In insert or ...


3

According to one of our former mods, the answer is no: Sending Control with a character from the 2nd column is useless. Control clears the 7th bit, but this is already 0, so Control+# will just send "#". Notice that & in the second column has binary representation 01 00110, so clearing the 0 doesn't help.


4

You can use <C-R> from insert mode to insert the contents of a register. That way you can insert the whole line at once, including the repeat of the variable name. For example: nnoremap <Leader>L "ayiwOconsole.log('<C-R>a:', <C-R>a);<Esc> You might want to consider adding a visual mode mapping as well, in which case you can ...


9

Can you guys think of a more elegant way to do the same? Well, at least we can try our best :-) nnoremap <silent><Leader>L :put! =printf('console.log(''%s:'', %s);', expand('<cword>'), expand('<cword>'))<CR>


0

You need to explicitly pass the key into the function; there's no built-in way to obtain that from Vim; this isn't a common use case. As plugins should only have a few keymappings, this approach should be fine. Metaprogramming (e.g. a :for loop) could be used to automatically define many mappings without duplicating all the information. function! GetInvoker(...


4

First, terminology: a chord is a key-combination like Ctrl-w—it is so-called because it is like the chords a pianist plays, with many keys pressed iw is really more of a key sequence. /end pendantry :) Your visual-mode mappings are screwing with the usual iw sequence. Once started with v, Visual mode does what you tell it to. In this case, you've sent ...


4

Your mapping is written badly: you don't need both <CR> and <bar> at the same time. Use either :cmd1<bar>cmd2<CR> or :cmd1<CR>:cmd2<CR>. Moreover, with set you can/should merge both settings into one command: :set invnumber invpaste<CR>. Another thing you should take into account is that number is local to window, ...


1

With winresizer, hit Ctrl-e and resize away! You'll use the regular hjkl keys (and maybe the arrow keys). You can "accept" the resize or "abort" it. There's also a move-mode where you swap windows around, and a focus-mode where you switch the window you're active in.


0

The following answer on stackoverflow explains why this is impossible: Due to the way that the keyboard input is handled internally, this unfortunately isn't generally possible today, even in GVIM. Some key combinations, like Ctrl + non-alphabetic cannot be mapped, and Ctrl + letter vs. Ctrl + Shift + letter cannot be distinguished.


0

Finger rolling describes typing keys such that successive keys are typed moving towards the center of the keyboard (inward rolling) or edges of the keyboard (outward rolling). Said another way, going from your pinky to your index finger, or the reverse. It's like drumming your fingers (see picture). On a Qwerty keyboard "asdf" and "awe" are examples of ...


4

Yes, you can use the <nowait> modifier. See here, copied from the documentation: *:map-<nowait>* *:map-nowait* When defining a buffer-local mapping for "," there may be a global mapping that starts with ",". Then you need to type another character for Vim to know whether to use the "," mapping or the longer one. To ...


Top 50 recent answers are included