How to disable NERDTree when the DirDiff plugin is in use - vim

I've just started using the NERDTree vim plugin and am generally pleased with it. I also sometimes use the DirDiff plugin. My most frequent use of the DirDiff plugin is for git diff via this stack overflow explanation.
I'd like to configure NERDTree to be automatically closed when the DirDiff plugin in effect. Is this possible via my .vimrc? I install these plugins via vim-plug.

You can create a custom function that triggers DirDiff and uses :NERDTreeClose as dependency and bind that custom function to keymap that you using for DirDiff.
You can also try to play around with autocmd BufEnter.
I remember this was my problem as well, if you find solution combining my suggestion please post it here.

Related

Ideavim plugin for Intellij keymaps

I'm trying to get the Ideavim plugin to work correctly in Intellij IDEA and PyCharm, but the documentation is rather poor and I can't configure it properly.
For starters, the documentation tells me to choose the VIM keymap under Preferences/Keymap but there is no VIM keymap there before or after installing Ideavim.
Also, according to the documentation some plugins are suposed to be supported (altough the documentation doesn't say wich and only talks about vim-surreound), but even after putting the line in ~/.ideavimrc:
set vim-surround
The vim-surround commands simply don't work.
Also, where are the actions/commands list that can be used in ~/.ideavimrc to map some keybinding.
For instance, imagine I want to remap <leader> f s to save my file. Where do I find out the commands available so that I can put something like in ~/.ideavimrc:
let mapleader = " "
nmap <LEADER>fs :SaveFile<CR>
Vim-surround emulation is not released yet. You can download CI builds that include vim-surround support using a link at https://github.com/JetBrains/ideavim.
In order to enable vim-surround, use:
set surround
You can list all the IDE commands available for mapping using :actionlist. See the documentation at the GitHub page.
Update: IdeaVim 0.46 supports vim-surround commands.

How can I use vim plugins with Ideavim?

I would like to use Tim Pope's vim surround plugin in my Pycharm IDE. I've been using the IdeaVim plugin for Pycharm to use vim motions and commands.
I know I can use ~/.ideavimrc like my normal .vimrc but I cannot find
information about how to use plugins with ideavim.
Can I specify the plugins directory inside my ~/.ideavimrc or do I have to go another way? Can I use a plugin manager like pathogen?
The latest version of IdeaVim includes the vim-surround plugin. Enable it by adding
set surround
to your .ideavimrc file
https://github.com/JetBrains/ideavim#emulated-vim-plugins
Most applications only emulate Vim's / vi key bindings (and often only the basic navigation and editing commands). That goes a long way to helping vi users edit comfortably, but it isn't the real thing.
Unfortunately, to be able to use Vim plugins, you'll need the full Vimscript interpreter and infrastructure around 'runtimepath'. I'm not aware of any application that provides this, and because of the complexities and idiosyncrasies of Vim, this would be very hard indeed.
To get more of Vim's special capabilities into your IDE, use both concurrently; it is very easy to set up a external tool in your IDE that launches Vim with the current file (and position). Automatic reloading of changes allows you to edit source code in both concurrently.
If it's any comfort to you, the same applies to Emacs / Elisp as well.
The ideaVim plugin added "Support for vim-surround commands ys, cs, ds, S, enable it with set surround in your ~/.ideavimrc" since version 0.46.
No. Vote for VIM-506 for Vim scripts support (unlikely to be implemented) and for VIM-769 for vim-surround emulation (likely to appear in future versions).
This was mentioned in a changelog relatively recently.
https://github.com/JetBrains/ideavim/blob/master/CHANGES.md#features-5
I didn't mange this work. Looks like I need vim-plug installed and I use another package manager in my NeoVim and also I don't want to mix up two configs. It should work in general.

Can I write Vimscript in my IdeaVim .ideavimrc file?

I am experimenting with Vim mode in the various JetBrains editors, using their IdeaVim plugin.
I'm trying to port over some of the existing functionality from my native .vimrc file. However, I don't seem to be able to get even the simplest vimscript function to work in my ~/.ideavimrc file.
After some searching I can't determine if this is something that IdeaVim even supports. Can I execute functions in the JetBrains editors with the IdeaVim plugin enabled?
You can use only a very limited set of Vim commands like some "set" options, various "map" commands, etc. See the IdeaVim repository on GitHub for more info.

How to make vim pathogen to reload plugins?

Is it possible to make vim to reload pathogen plugins without restarting vim?
I have opened vim with many files, then I add plugin to:
~/.vim/bundle
Since now I'd like to force vim to use the new plugin.
Pathogen just manipulates the 'runtimepath' option; the situation with plugin reloads is therefore the same as with the plain default plugin structure. (Other plugin managers may offer this kind of reload / dynamic enable functionality; I suppose you want to stick with Pathogen.)
To retroactively enable a plugin in a running Vim session, you need to :source all (usually that's only one) plugin scripts that have been added. For a plugin named foobar, that would be:
:source ~/.vim/bundle/foobar/plugin/foobar.vim
If you can get Pathogen to re-initialize the 'runtimepath' (or augment it yourself via :set rtp+=~/.vim/bundle/foobar), you can also use the shorter
:runtime plugin/foobar.vim
If you use a modern version of vim, you can use its built-in package manager, which has a convenient function to reload all plugins:
:packloadall
http://vimhelp.appspot.com/repeat.txt.html#%3Apackloadall
I was in the same boat before util I find an awesome plugin(vim-reload) to do these stuffs automatic in an amazing way.You should have a shot at this plugin.

How can I reload a VIM plugin after VIM was started?

I am modifying an installed VIM plugin and in another Terminal tab I am testing the results.
Each time I want to test the changes I have to restart VIM.
Is there any faster way to do this process? How can I reload a VIM plugin after VIM was started?
The plugin is installed via Vundle
I have tried to run :so % that is supposed to reload the .vimrc file but I still cannot see my changes.
If there weren't an inclusion guard (if ! exists('g:loaded_pluginname') ...), you could simply :runtime! plugin/pluginname.vim (or :source % if it's currently opened) and all plugin definitions would be re-read.
But as most plugins (correctly) use such a guard, you need to :unlet that variable first:
:unlet g:loaded_pluginname | runtime! plugin/pluginname.vim
My ReloadScript plugin can do this with one command if the guard name adheres to the canonical naming, and the scriptease plugin has such a command, too.
Edit: Some plugins use differently named guard variables, or other ways that prevent reloading. The plugins from mattn (like emmet.vim) are quite elaborate; maybe there's some special mechanism; I don't use that plugin. You could ask the author for advice, though.

Resources