Questions tagged [map-operator]
Use this tag for questions about creating your own operator within vim.
41
questions
1
vote
2
answers
55
views
Unmap error in filetype autocommand
I use a plugin for todo.txt file (https://gitlab.com/dbeniamine/todo.txt-vim).
Because I mapped some d[other_letters] in my .vimrc and there's a \d mapped in the plugin, to avoid delays when I type \d ...
1
vote
1
answer
90
views
Get motion used within operatorfunction?
How can I make a custom operator function that can programmatically reuse the motion that the user called it with?
E.g. I want to map the operator m so that miw goes to the start of the file and then ...
2
votes
1
answer
59
views
Different replace patterns depending on visual/visual line mode
I've written some customizations in my .vimrc that I would like to further improve and refine.
In particular, for some key combinations, I'm doing text substitutions, like this:
vmap <C-S-w> :s/\...
0
votes
1
answer
33
views
Opfunc inserts text before cursor position sometimes
function! s:Surround(motion = "") abort
let [_, l:start_row, l:start_col, _] = getpos("'[")
let [_, l:end_row, l:end_col, _] = getpos("']")
let l:before = &...
0
votes
1
answer
204
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:...
0
votes
1
answer
47
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 ...
2
votes
1
answer
133
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> :...
0
votes
2
answers
208
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
1
answer
92
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
1
answer
139
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
1
answer
47
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
2
answers
90
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'...
3
votes
1
answer
530
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
1
answer
47
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 -- ...
11
votes
1
answer
397
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
1
answer
42
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
1
answer
119
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
2
answers
509
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
1
answer
57
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
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&...
4
votes
1
answer
701
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
1
answer
117
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
2
answers
241
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}&...
6
votes
1
answer
291
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
1
answer
92
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
0
answers
41
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
1
answer
76
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
1
answer
225
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
1
answer
370
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
2
answers
284
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
1
answer
452
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
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 ...
0
votes
1
answer
173
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
1
answer
771
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
1
answer
250
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
1
answer
58
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
1
answer
101
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
1
answer
122
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
1
answer
276
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
0
answers
145
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
1
answer
99
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. ...