how to ideavim combine two action - vim

Hi I'm try to customize my ~/_ideavim like this
nmap za :action ReformatCode<CR>
nmap zb :action RiderUnitTestRunSolutionAction<CR>
nmap zc :action ReformatCode<CR>:action RiderUnitTestRunSolutionAction<CR>
when I try press za and zb it work very well
it can be format my Code Or run the unit tests
But when I try to combine two action like zc
it just work last action .
If it possible Run Test after Reformat ?

You can run multiple commands at once with the |
nmap zc :action ReformatCode \| action RiderUnitTestRunSolutionAction<CR>

Related

How to use Control+arrow to switch vim tabs in screen?

I have configured vim to use the control+arrow to switch tabs by adding following lines in .vimrc:
map <F7> :tabp<cr>
map <F8> :tabn<cr>
map <C-up> :tabr<cr>
map <C-down> :tabl<cr>
map <C-left> :tabp<cr>
map <C-right> :tabn<cr>
In screen, the <F7> and <F8> works, but the control+arrows do not...
Any idea why? And how to fix? Thanks.
I'm not sure it will work, but you could try to include this code inside your vimrc:
if &term =~ '^screen'
sil! exe "set <xUp>=\e[1;*A"
sil! exe "set <xDown>=\e[1;*B"
sil! exe "set <xRight>=\e[1;*C"
sil! exe "set <xLeft>=\e[1;*D"
endif
I copied it from here.
If you use tmux, you may also need to enable the option xterm-keys inside your tmux config file (~/.tmux.conf):
set-option -gw xterm-keys on
It's described in man tmux:
xterm-keys [on | off]
If this option is set, tmux will generate xterm(1) -style function key sequences; these have a
number included to indicate modifiers such as Shift, Alt or Ctrl. The default is off.
I don't know what the equivalent for screen is.
It's also possible that something (window manager, terminal multiplexer, terminal emulator) is intercepting <C-left> before Vim.
To rule out this possibility, you could try to insert <C-left> literally in a Vim buffer by typing C-v C-left, in insert mode, and see what it displays. On my machine, it displays ^[[1;5D, so I know that nothing intercepts <C-left>.
If nothing is displayed, then you will have to find which software is intercepting <C-left> and remove the key binding in its configuration.

Resize Splits in Vim after NERDTreeToggle

I am looking for a way to automatically resize my open v-split panes in Vim after I call NERDTreeToggle.
I have NERDTreeToggle being called on the shortcut "ctrl+\" at the moment, and ideally what I want is to call the keyboard shortcut "ctrl+w =" immediately afterwards.
Any ideas? Thanks.
If this is your current mapping:
:nnoremap <C-\> :NERDTreeToggle<CR>
You can just append the window command after it:
:nnoremap <C-\> :NERDTreeToggle<CR><C-w>=
Alternatively, you can execute this from command-line mode as well, via :normal!:
:nnoremap <C-\> :NERDTreeToggle<Bar>execute "normal! \<lt>C-w>="<CR>
Note that for window commands, there's also a special :wincmd to invoke them:
:nnoremap <C-\> :NERDTreeToggle<Bar>wincmd =<CR>

Extend a vim command

How can I extend a command in vim?
I want to do it in two situations,
After a :diffget or :diffput I always want to run a :diffupdate
After a :NERDTreeToggle I want to run a <C-w>=
I am unaware of any autocmd events that would be triggered for your scenarios. However a few custom mappings might be helpful.
You can change the default dp and do mappings to also do a :diffupdate
nnoremap dp dp:diffupdate<cr>
nnoremap do do:diffupdate<cr>
Note there are times where you cannot use dp and/or do and must use :diffput/:diffget. In these cases I would suggest you create a commands like so:
command! -nargs=? -range=1 -bar Diffput <line1>,<line2>diffput <args>|diffupdate
command! -nargs=? -range=1 -bar Diffget <line1>,<line2>diffget <args>|diffupdate
Or you can just map :diffupdate
nnoremap <f8> :diffupdate<cr>
NERDTree
nnoremap <leader>N :NERDTreeToggle<cr><c-w>=
Maybe you can have a look to the vim macro. It is probably suitable for what you want to do :).
Create your own custom function in VimScript in your .vimrc that wraps several commands.
Here's one I use to launch a Clojure Repl in a buffer using several plugins:
fun! LeinCMD()
execute 'ConqueTerm lein repl'
execute 'set syntax=clojure'
execute 'normal! i'
endf
command! Repl call LeinCMD()
I then call this command with :Repl (note that your custom commands must always start with an uppercase letter).
Source: Automate running several vim commands and keystrokes

Why doesn't my vim mapping work?

I followed the guide here to create vim mapppings. Put the following in my .vimrc file
let mapleader=','
if exists(":Tabularize")
nmap <Leader>a= :Tabularize /=<CR>
vmap <Leader>a= :Tabularize /=<CR>
nmap <Leader>a: :Tabularize /:\zs<CR>
vmap <Leader>a: :Tabularize /:\zs<CR>
endif
The page says when I type ,a= it should tell Tabularize to align my lines. But instead it inserts the character = where the cursor is.
I have Tabularize installed and the :Tabularize command does work when I call it without mapping.
What am I doing wrong?
Your .vimrc file is read and executed before plugins are loaded, so :Tabularize isn't defined.
To find out the exact order in which the various scripts are called at startup you can run the command:
:scriptnames
and you can learn the details about the initialization process with:
:help startup
Make sure that you set your mapleader to ,. Originally it is mapped to \.
To accomplish this add this to your vimrc or type in the command window:
let mapleader=","
Although from your code it looks like you are doing this, you have to make sure that it didn't get reset somewhere. In order to see what it is set to currently type let mapleader in the command window.

vim redraw does not redraw on OSX 10.6

I'm trying to open a PDF file from Vim using the commands
let openpdfname = "!open " . expand("%:t:r") . ".pdf"
map <F6> :silent execute openpdfname<CR> | redraw!
The PDF opens up in Preview and all is well, except that the Vim screen is not repainted. I use vim 7.2.108 (shipped standard with OSX 10.6) from the terminal window. I tried removing my ~/.vimrc entirely to try and determine the cause, with no luck.
Hitting Ctrl-L repaints the screen, but I thought 'redraw!' would have the same effect!?
Thanks for any hints!
Move <CR> to the end of mapping. You are trying to execute redraw after you exited command mode. Of course, it does not work.
The correct syntax that does what I expect is:
map <F6> :silent execute openpdfname<CR>:redraw!<CR>
Try this:
map <silent> <F6> :silent execute openpdfname<CR>

Resources