Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Questions tagged [map-operator]

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

Filter by
Sorted by
Tagged with
0 votes
1 answer
33 views

How to pass arguments to `:map gx <Plug>(SomeFunction)`?

Context I'm evaluating https://github.com/tyru/open-browser.vim which looks really promising. I figured out how to set the default search engine and add a mapping " vim-openbrowser let g:...
user avatar
0 votes
1 answer
32 views

Meta-Model: Shrinking In Correct Direction

This questions sounds ridicolous, but is there any (mental?!) aid for my struggle when resizing windows? Since the earliest days of my vi/m usage, I have struggle shrinking windows in the correct ...
user avatar
  • 31
2 votes
1 answer
47 views

What is the purpose to use "==#" with empty string?

The following is from vim-sensible plugin: set incsearch " Use <C-L> to clear the highlighting of :set hlsearch. if maparg('<C-L>', 'n') ==# '' nnoremap <silent> <C-L> :...
user avatar
0 votes
2 answers
89 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 & ...
user avatar
  • 103
0 votes
1 answer
41 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, ...
user avatar
  • 1,303
1 vote
1 answer
114 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 ...
user avatar
0 votes
1 answer
25 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 ...
user avatar
0 votes
2 answers
58 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'...
user avatar
2 votes
1 answer
132 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 /...
user avatar
1 vote
1 answer
29 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 -- ...
user avatar
  • 325
9 votes
1 answer
232 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 ...
user avatar
1 vote
1 answer
25 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('$') ?...
user avatar
1 vote
1 answer
85 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 ...
user avatar
1 vote
2 answers
403 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 ...
user avatar
2 votes
1 answer
31 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 ...
user avatar
  • 123
1 vote
0 answers
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&...
user avatar
  • 1,117
4 votes
1 answer
412 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 ...
user avatar
  • 43
2 votes
1 answer
76 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. ...
user avatar
0 votes
2 answers
88 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}&...
user avatar
6 votes
1 answer
207 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(...
user avatar
  • 5,868
2 votes
1 answer
75 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-...
user avatar
2 votes
0 answers
38 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. ...
user avatar
  • 103
0 votes
1 answer
58 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 ...
user avatar
2 votes
1 answer
191 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 ...
user avatar
4 votes
1 answer
263 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 ...
user avatar
  • 20.6k
3 votes
2 answers
238 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"...
user avatar
  • 1,507
2 votes
1 answer
308 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 ...
user avatar
2 votes
1 answer
63 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 ...
user avatar
0 votes
1 answer
157 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 ...
user avatar
9 votes
1 answer
697 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 ...
user avatar
  • 16.5k
1 vote
1 answer
173 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 ...
user avatar
  • 300
1 vote
1 answer
54 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 ...
user avatar
  • 827
1 vote
1 answer
94 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 ...
user avatar
2 votes
1 answer
117 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 &...
user avatar
  • 209
3 votes
1 answer
234 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 ...
user avatar
  • 912
2 votes
0 answers
126 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 ...
user avatar
  • 1,804
8 votes
1 answer
81 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. ...
user avatar