Questions tagged [map-operator]

Use this tag for questions about creating your own operator within vim.

Filter by
Sorted by
Tagged with
0
votes
2answers
29 views

using EasyAlign in a function

I frequently use EasyAlign in my tex files to align tables around the $ delimiter such that this header1 & header2 & header3 \\ data1 & data2 & data3 \\ becomes this header1 & ...
0
votes
1answer
24 views

Can I allow additional arguments in an operatorfunc?

To call a custom operator with a mapping, one can do nnoremap <Plug>(Foo) :set opfunc=Baa<CR>g@ so that <Plug>(Foo) expects a motion, after which the function Baa is called. Here, ...
1
vote
1answer
107 views

Auto pairing using strings instead of characters

I'm already aware of existing solution to automatically "surround" sentences/word/etc (eg: auto-surround, vim-surround, etc) but those (as far as i know) don't support using normal strings ...
0
votes
1answer
17 views

How to map <Plug>MarkdownPreviewToggle

I am trying to map MarkdownPreviewToggle to an key like "mk". My vimrc is like it: nnoremap mk <Plug>MarkdownPreviewToggle But it doesnt work, what should i do? (the other key isnt ...
0
votes
0answers
26 views

Modifying 'showcmd' output

The documentation for g@ shows an example where <F4> is remapped to count spaces corresponding to the subsequent motion, using 'operatorfunc' and g@. The usage of g@ in the mapping results in ...
0
votes
2answers
55 views

Bind a specific search to a map in normal mode

Specifically, I'm looking to bind the search /\(<<<<\|====\|>>>>\)/ (i.e. "find the next git merge boundary"). Ideally to <C-/> or <A-/>, but that part I'...
2
votes
1answer
42 views

Create a mapping that works whilst searching

I have jk remapped to <Esc> in insert mode and for some reason my brain always want's to exit a search by typing jk. I would like to remap jk to <CR> when performing a search. I.e typing /...
1
vote
1answer
24 views

How to prevent cursor shift when using <C-O>{delete cmd} at the end of a line?

<C-w> deletes a (small-)word in insert mode, but I often want to delete the Word (to last whitespace) I've most recently typed. I tried inoremap <C-_> <C-o>dB which kind-of works -- ...
9
votes
1answer
141 views

Why does `<Bar>` behave like `|` in the `:command` command in Vim?

Here is the list of experiments I performed that shows that <Bar> is treated as literal <Bar> in some commands but it is treated as | in the :command command. I am trying to understand why ...
1
vote
1answer
23 views

How to test whether the cursor is at the end of a line in a mapping?

I would like to test in an operator-pending mapping whether the cursor is on the last position of the line. I currently have this, but it does not work: onoremap <expr> i$ col('.') == col('$') ?...
1
vote
1answer
66 views

How to ignore or silence errors in operator-pending mappings?

The following operator-depending mapping works great for me, onoremap <silent> a$ :<C-U>normal! hEF$v,<CR> except when it is issued at the very beginning of a line. What happens is ...
1
vote
2answers
307 views

Problem remapping § to esc in vim on a macbook with touch-bar

I am using a macbook with touchbar. As many others I would like to map a different key to the esc key, since the touchbar esc is a bit inconvenient. My problem is that I have some weird behaviour of ...
2
votes
1answer
20 views

Can't exit buffer using leader mapping - 'cannot make changes'

I have a leader key set up, and a mapping that allows me to exit windows without typing :: let mapleader = 'f' map <leader>q = :q<CR> Today I installed MattesGroeger/vim-bookmarks using ...
1
vote
0answers
17 views

How can I :map a key to something containing spaces? [duplicate]

I want to :map <C-t> :some-ex-command with a space at the end so I can continue typing the command and execute it with enter. I cannot find the syntax for how to do this. I tried :map <C-t&...
4
votes
1answer
243 views

Open command-line-mode from VimScript function

How to reproduce this mapping: nnoremap <Leader>a :DoSomething <C-r>=do_something_arguments()<CR> ..in a function? The desired effect is to open command-line mode with some text ...
2
votes
1answer
58 views

Map <C-J> to <Space> in all possible modes

My space bar no longer works unless I lean my weight on it. The chances of getting the laptop replaced in a timely manner is close no nil. I mostly use vim or vi, even from the bash command line. ...
0
votes
2answers
58 views

how can i remap <C-w>{number}h to <C-w>{number}j

I am trying to remap my hjkl keys to jklö. this is not a problem in most simple cases, but with commands like <C-w>h where you can specify an amount in the form of <C-w>{count}h or {count}&...
5
votes
1answer
162 views

How to pass v:register to custom operator when working on custom text object?

I have a simple custom operator, it echoes v:register, it's mapped to ,f. After reading this, i creat it like this : function! s:foo(type,...) echo v:register endfunction function! s:setupOpfunc(...
2
votes
1answer
66 views

Alternate vim mapping

I have a file that looks something like this \usepackage{tex/Forkurs-1p-2p-laererutdanning-2018-V} \usepackage{../Sty/hyper} \begin{document} \input{tex/Forkurs-1p-2p-laererutdanning-2018-V-...
2
votes
0answers
33 views

Do operator ranges/movements/textobjects always overwrite the last visual selection? workaround?

In vim, when I operate on a textobject from a plugin, say the 'inner indent' typed ii from kana/vim-textobj-indent, my last visual selection ('>, '<) is reset to where the operator worked on. ...
0
votes
1answer
48 views

Mappings with counts at the end without using loops?

Suppose you are trying to create a set of mappings such that pressing <C-t> followed by a number # would alternate to the respective tab at index #. I know that using a loop, I can do: " Map ...
2
votes
1answer
177 views

Numpad characters don't work in keybindings mappings (but work in general)

For my terminal Vim 8.0, I have downloaded this plugin that makes changing font size on the fly easy: https://github.com/drmikehenry/vim-fontsize Following the instructions, here is how I decided to ...
4
votes
1answer
197 views

Modify `iskeyword` for keyword-local completion only

Context Some time ago, I added the following line to ~/.vim/after/ftplugin/sh.vim to make working with parameter expansions easier: setlocal iskeyword+=$ This is nice to be able to e.g. ysiw" via ...
3
votes
2answers
204 views

overwrite motion-wiseness of operator pending mode

Background In :h motion.txt, it says: FORCING A MOTION TO BE LINEWISE, CHARACTERWISE OR BLOCKWISE When a motion is not of the type you would like to use, you can force another type by using "v", "V"...
2
votes
1answer
231 views

Operator pending mode remaps not working

I'm trying to build a vimscript can be used with the Dvorak Simplified Layout. I.e., given that the keys on the keyboard plugged into the computer are laid out in the Dovark Simplified Layout (and the ...
2
votes
1answer
62 views

change inner backslashed quotes

I know the ci" motion and others :changes, but I need something like a ci\" in order to change inner a backslashed quotes. Assuming * as the cursor position: a = "message says: \"fo*o bar\"" I would ...
0
votes
1answer
130 views

how to accept count for visual block ctrl+a remap?

I have created a vmap but I can't figure out how to apply a count to it. In this case, the mapping is on <C-a> and 4<C-a> is an example of a command with a count failing to be applied. We ...
9
votes
1answer
634 views

How to allow count *before* my custom operator?

I'd like to define my own operator. Vim's builtin help has a nice little tutorial on it, where they show you can create your own operator with opfunc and g@: nmap <silent> <F4> :set ...
1
vote
1answer
165 views

How to cancel a custom operator-pending command

I want to make a custom search, accessible with operator-pending commands; I use onoremap to make it work in this mode. It's working well, and I can use my command (let's say it's mapped to zz) with ...
1
vote
1answer
52 views

Problem mapping operator

I'm trying to write a mapping that will copy the text and automatically unwrap it at the same time. Here's what I got: function! CopyUnwrapped(type, ...) if a:0 normal! gv"ay else ...
1
vote
1answer
85 views

onoremap: defining a bounded region

I want to craft a custom operator-pending motion if for functions in R language that look like this: doSomething <- function(arg1, arg2, ...) { doStuff(...) } The idea is to be able to press ...
2
votes
1answer
109 views

Is there a way to make the `r` operator accept a motion?

What I would like to do is issue a raiw where the current word would be replaced by an aaaaa word. example: this is a w[o]rd <--- cursor on [] raiw <--- command this is a aaaa &...
3
votes
1answer
210 views

Abort an operating pending mapping

When creating an operator pending mapping in vim, it is possible make the mapping work on an arbitrary (consecutive) piece of text. I am looking for a way to abort the operation. For the case of ...
2
votes
0answers
120 views

Avoid ending up in mode from onoremap

When I'm on an empty line and press cfa, nothing happens, whereas on a line with an a, it will go into insert mode. E.g. I have this: onoremap <silent> a :normal! Favfz Whether I am on an ...
8
votes
1answer
75 views

Define text object that depends on the current operator

I'm curious if it is possible to make a text object aware of its operator. In particular, I am writing a text object for LaTeX environments, where I want different behaviour depending on the operator. ...