Simpler way to make mappings which work with all text objects in Ideavim? - ideavim

I'm used to using https://www.vim.org/scripts/script.php?script_id=2703 for replacing a text object in Vim and I'm now in the process of recreating some of this functionality in IdeaVim.
I'm using these mappings in my vimrc:
nmap Ö <Plug>ReplaceWithRegisterOperator$
nmap öö <Plug>ReplaceWithRegisterLine
xmap ö <Plug>ReplaceWithRegisterVisual
nmap ö <Plug>ReplaceWithRegisterOperator
The first 3 lines are easy to recreate in my .ideavimrc like this:
nnoremap Ö "_Dp
nnoremap öö "_ddP
vnoremap ö "_dP
But is this really the best way to get ö to work with every single text object in normal mode?
nnoremap öiw "_diwP
nnoremap öaw "_dawP
nnoremap öIw "_dIwP
nnoremap öAw "_dAwP
nnoremap öis "_disP
nnoremap öas "_dasP
nnoremap öip "_dipP
nnoremap öap "_dapP
nnoremap öib "_dibP
nnoremap öab "_dabP
nnoremap öiB "_diBP
nnoremap öaB "_daBP
nnoremap öi( "_di(P
nnoremap öi) "_di)P
nnoremap öa( "_da(P
nnoremap öa) "_da)P
nnoremap öi[ "_di[P
nnoremap öi] "_di]P
nnoremap öa[ "_da[P
nnoremap öa] "_da]P
nnoremap öi{ "_di{P
nnoremap öi} "_di}P
nnoremap öa{ "_da{P
nnoremap öa} "_da}P
nnoremap öi< "_di<P
nnoremap öi> "_di>P
nnoremap öa< "_da<P
nnoremap öa> "_da>P
nnoremap öi" "_di"P
nnoremap öa" "_da"P
nnoremap öi' "_di'P
nnoremap öa' "_da'P
nnoremap öi` "_di`P
nnoremap öa` "_da`P
nnoremap öit "_ditP
nnoremap öat "_datP
These mappings do work, but I was wondering if there would be a cleaner and simpler way to accomplish this?

You can map custom operators with :map-operator, but this feature is not yet supported by IdeaVim.
You can create an issue if you like.

Related

How to keep search window?

Disclaimer: I don't know all the correct terminology here. When I say "window" it might be "quickfix modal dialog" or something.
I am using Neovim (through Neovide) and have these settings to enable search via the fzf plugin, by way of ripgrep:
" Search / Grep
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ 'rg --column --line-number --no-heading --color=always --smart-case '.shellescape(<q-args>), 1,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
\ <bang>0)
set grepprg=rg\ --vimgrep
" set ctrl-p similarities to open files
nnoremap <silent> <C-t> :Files <cr>
nnoremap <silent> <C-p> :Files <cr>
nnoremap <silent> <C-b> :Buffers<cr>
nnoremap <silent> <C-M-h> :History<cr>
" disable preview window
let g:fzf_preview_window = ''
In my environment vars, I have FZF_DEFAULT_COMMAND set to:
rg --files --hidden --glob "!.git/*"
When I do something like :Rg fn I get a popup window that looks like this:
Here's the problem: when I hit enter to one of the lines to dismiss the window and go to the target file to make changes, I then want to bring the search window back up after I'm done.
I can hit : and then arrow up to re-run the search, but that can be pretty annoying, especially when there are many results and I want to keep the cursor around where it last left off. When I try :copen it's just empty.
Is there a way to re-open the last search in a window, preserving the state? (I understand the search results will be stale if I changed something... that's fine)
Aside for the specific question - I'd appreciate tips for working with search in the Neovim UI, for someone coming from GUI editors like VSCode.
Thanks!

How can I change the cursor keys in the VIM extension for vscode

I use the Colemak DH mod layout, which moves around the default keys used for navigation in normal mode. I was wondering if there was any way to remap the hjkl cursor key combo to mnei, or better yet, neio. I am not actually using vim, but rather using the VIM extension for vscode. I've been looking around the internet, but I couldn't find anything.
I know of two ways of doing so:
Approach 1 importing .vimrc
That's what I'm currently using. I have the following settings in the VSCode config, that make VIM plugin to load the specified vimrc file
"vim.vimrc.enable": true,
"vim.vimrc.path": "$HOME/.vim/vimrc_vscode",
And then in vimrc_vscode:
nnoremap j h
nnoremap k j
nnoremap h k
vnoremap j h
vnoremap k j
vnoremap h k
Approach 2 VS code settings
You can use the "non recursive" remapping setting to swap the keys the way you want.
Example (swap j and k):
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["j"],
"after": ["k"]
},
{
"before": ["k"],
"after": ["j"]
}
]
See more at https://github.com/VSCodeVim/Vim#viminsertmodekeybindingsnonrecursivenormalmodekeybindingsnonrecursivevisualmodekeybindingsnonrecursiveoperatorpendingmodekeybindingsnonrecursive

How to remap <cr> to go to line number in VSCodeVim

In vim I used to map the enter key <cr> to go to line number instead of the letter G using the following settings
nnoremap <expr> <cr> v:count == 0 ? "\<cr>" : "G"
I tried to achieve the same result in vim for VSCode but I couldn't.
Is there a way that manage me from doing so without enabling the experimental feature neovim integration inside VSCode

Yanking multi-line text in VIM doesn't paste into shell with line breaks

Windows10, Vim 7.4
When I paste multi-line yanked text into powershell (running with ConqueTerm plugin) I lose the line breaks. Pasting the same yanked lines into another vim (.txt) window preserves the line breaks as expected.
e.g.
abc
def
yanked and then pasted into powershell window I get
abcdef
instead of
abc
def
my vimrc:
behave mswin
set ff=dos
set shell=powershell
set shellcmdflag=-command
execute pathogen#infect()
syntax on
filetype plugin indent on
set tabstop=4
set softtabstop=4
set wildmenu
let mapleader=","
set relativenumber
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>

How can I see the places a function is being called in vim?

I have been using vim and ctags for going over Perl files.
I was wondering the following:
Is there a way/plugin I can use so that I can press a key combination and be able to see all the places a function is called (as easily as I can jump to the definition of a function or view the list of all functions with the same name in all files of my project with ctags)?
I have read about cscope but I am not sure if it is usable for Perl or there is a solution for scripting languages.
Maybe this is what you are looking for:
" Lists lines containing the word under the cursor. Type the line number
" followed by <CR> to jump to the corresponding line.
nnoremap [I [I:
xnoremap [I "vy:<C-u>ilist /<C-r>v<CR>:
" Same as above but for 'defines'
nnoremap [D [D:
xnoremap [D "vy:<C-u>dlist /<C-r>v<CR>:
Then position the cursor under a word and type [I or [D.