How to map a key sequence to an IdeaVim key mapping - android-studio

Currently, I'm attempting to organize some keyboard shortcuts for IdeaVim v0.48. I've run into a problem when I try to map shortcut "leader + ev" to an Intellij IDE action "ExtractVariable."
There is no official IDE action listed for extracting a variable, strangely enough, so I'm trying to map it to a function key. Here's what I put into my .ideavimrc:
set <F15> = ^[,
map <F15> <leader>ev
where my IDE shortcut for extracting a variable is "Ctrl + Alt + ,"
I've followed multiple guides on this, and still don't understand how to do it. Any ideas?

Answering my own question for others as the IJ Idea documentation is a little unclear:
The IDE action for "Extract Variable" is actually called "IntroduceVariable" if you want to call it from command mode (all other variable extraction actions begin with "Introduce" also). So to map this to a shortcut in IdeaVim, simply put this in your .ideavimrc:
map <what you want to use> :action IntroduceVariable<CR>

Related

Vim rename variable

Most people say vim is greatest editor.
But is there any way to rename variable as fast as sublime.
Example:
function f($items) {
$items;
....
$items;
}
In sublime:
Go to items variable
click ctrl+d 2 times
rename variable
In VIM:
Search for /items
cw
write the new name
"n" for next occurrence and then "." to repeat
In vim obviously the keystrokes are more.
Does anyone knows easier and faster rename variable method?
Thank you
There are few solutions:
Change command
Go to items and then hit:
*Ncgn{new name}<Esc>
And then you can . through rest of the files.
Plugin
I have written plugin which simplifies this flow sad.vim which simplifies above to:
siw{new name}<Esc>
And then you can . through rest of the occurrences.
Substitute
Select function body by vi{ and then call:
:'<,'>s/items/{new name}/g
Language Server
If your language has Language Server that supports renames then you can use one of the many LS clients for Vim out there and use the support from there.
The point is: in vim the moviment towards the target change point happens without touching the mouse, and it can also be made via terminal through a ssh session. You should also consider this. I have the following map:
:nnoremap c* *<C-o>cgn
Once you hit the variable just type c* followed by the new name, Esc and dot

How can I write to multiple lines simultaneously in Geany?

I want to modify the beginning of every line of a txt file in Geany. Somehow it is possible to write in multiple lines at the same time (maybe with box selection?).
How to do this?
You need to install before the plugin Extra Selection.
For my configuration (Debian/Buster, Geany 1.33) I add to configure shortcuts key.
See plugin manual for more details :
Usage :
Under Tools -> Extra Selection, there are 7 new items: "Column
Mode", "Select to Line", "Select to Matching Brace", "Toggle
Rectangular/Stream", "Set Anchor", "Select to Anchor" and "Rectangle
Select to Anchor". Normally these should be bound to keys, for example
Alt-C, Alt-Shift-L, Ctrl-Shift-B, Ctrl+2, F12, Shift-F12 and
Alt-Shift-F12.
This is just an addition to the answer by #zaboop since the edit queue was full and many people might not have understood the solution properly.
In Geany you cannot edit different parts of multiple lines at once (like in VS Code) without using plugins.
Instead what you can do is you can edit the starting of multiple lines at once.To do so:
Hold Shift + Alt and press your up or down arrow keys to correspondingly select the lines above or below the current line.
Then release Shift + Alt and continue editing the lines.
No plugins needed.
Strangely, unlike the other answers, I had to press Shift + Ctrl while selecting a region, and selecting only works with the mouse, not with the keyboard. After selecting, I was able to edit multiple lines at once.
Configuration: (Debian-based) Raspberry Pi OS, accessed via VNC, Geany 1.33
Select the region, while pressing Alt-Shift, then move around with cursor with arrows.

SublimeText3 Fold/Unfold all methods

I am using SublimeText3 for C++ and Java. I am wondering if there is a way to fold all of the methods in a file / class, and then unfold them all, regardless of where the caret is. Or is there a way to list all the functions / methods.
Basically I would like to be able to enter a file and see all the methods at one quick glance.
Thanks
Using the Sublime Text 3 menu, you can find EDIT -> Code Folding -> which exposes the folding methods and will helpfully tell you the default keyboard shortcuts they are assigned to.
By default you press Ctrl+K, then Ctrl+1 to fold all subroutines. Then, to unfold all I would press Ctrl+K then Ctrl+J.
If this does not work for your file type / syntax, try Ctrl+K, Ctrl+2 and above to see if another folding level works for you.
Unfortunately for me, the proprietary code I work with required custom syntax and a custom function written in our in-house package to fold all of our functions (a new sublime command written in python and installed as a package).
More simple
Select the code and press:
Ctrl + Shift + [ to fold
Ctrl + Shift + ] to unfold
Updates
You can also select an element. Exemple:
Open the console (View -> Console or Ctrl`) with a source code file focused and enter the following commands at the bottom:
view.run_command("fold_all")
view.run_command("unfold_all")
to see their effect.
These commands can be bound with custom key bindings or put into the Command Palette for easy use.
Mac: Go to Edit/Code Folding as image bellow:
Details image

emmet-vim, custom map using <plug> causing problems

I am trying to use to remap the emmet-vim functions, but I have some problems :
using :
map <c-e>e <plug>(EmmetExpandAbbr)
nmap <c-e>e <plug>(EmmetExpandAbbr)
or
map! <c-e>e <plug>(EmmetExpandAbbr)
nothing appens in any mode,
and using :
imap <c-e>e <plug>(EmmetExpandAbbr)
then comes a weird problem :
first, doing the sequence e in editmode,
div_
( '_' = cursor position)
becomes :
div<Plug>(EmmetExpandAbbr)_
And moreover, strange thing, the original map <c-y>, give the same result...
I heard that the map using is a better way to permit the user to custom the shortcuts rather than using global variables... So how to do this with the emmet plug-in (I already succeed to custom shortcuts with other plugins)?
Thank you !

What does <++> mean in gvim? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
What does <++> mean in vim (latex-suite), and how do I jump there?
My default editor is vim but I shifted to gvim for the latex suite. Whenever I type $$ in quick succession it adds a <++> after the second $ symbol. What does that mean and how do i disable that?
From the Vim-Latex FAQ:
Q: What are those annoying «» characters whenever I invoke a
mapping?
Those are called placeholders and when you get used to them, they
will prove invaluable. They are essentially markers left in the text
file to tell latex-suite where the next point of interest is. This
lets you directly go to the next placeholder with a single key-press.
Consider a working example. Pressing EFI will insert the following
micro template:
\begin{figure}[h]
\centerline{\psfig{figure=«eps file»}}
\caption{«caption text»}
\label{fig:«label»}
\end{figure}«»
The text «eps file» will be selected and vim will be left in
select-mode so that the user can continue typing straight away. After
having typed in the file name, she can press Control-J (while still in
insert-mode). This will take her directly to the next "place-holder".
i.e, «caption text» will be visually selected with vim in select
mode again for typing in the caption. This saves on a lot of key
presses.
If you still do not feel like using placeholders, include let g:Imap_UsePlaceHolders = 0
in your .vimrc.

Resources