Ideavim plugin for Intellij keymaps - vim

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.

Related

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.

Why vim's <Leader> key not working when I want to use bufexplorer or vim-buffergator plugin?

I am using Ubuntu now.
I used vundle installed bufexplorer and vim-buffergator plugin for vim. But when I type ¥be or ¥b, the <Leader> key ¥ not working in the vim editor. Is it necessary to set something in the ~/.vimrc file?
I didn't meet this problem until now, even I used Ubuntu or CentOS before.
Check out whether the mappings have actually been defined via:
:verbose nmap <Leader>b
This will also show what key the <Leader> key is configured to. If there's no output, check whether the plugin has been correctly installed (output of :scriptnames lists the plugin script, commands like :BufExplorer are available, etc.)
vim-buffergator explanation mentioned conflict with bufexplorer.
From https://github.com/jeetsukumaran/vim-buffergator :
[NOTE: If you have other plugins installed that have key maps that start with "<Leader>b" (e.g., BufExplorer, which uses "<Leader>bs", "<Leader>bv", etc.), then you may notice a slight delay or lag when typing the default "<Leader>b" to start Buffergator. In this case, you should either use another keymap for Buffergator or BufExplorer.]

Use code completion in vim as in sublime text

I would to have a autocompletion exactly as in sublime text but in vim.
I want this behaviour :
When I start to type a word, I want to have a box which suggest completions;
In the suggested completions, I want to have last words used;
I want to have functions finded through ctags;
I want to have standard functions for the language I'm using;
I want to have snippets;
There is a lot of plugins about autocompletion for vim and I'm lost.
Currently I'm using YouCompleteMe... It's very good, though I dunno whether it can be configured to sort words based on last usage. It has general fuzzy completion capabilities that will work on any file type (you may find fuzzy completion awesome), but it also contains semantic completion for C/C++/Objective-C/Objective-C++ through libclang.
Particularly, I aways compile the lastest clang, libc++ and VIM from sources to tune and set VIM to use my environment python/ruby/etc and get a decent C++11 support. I then, compile YouCompleteMe from sources too, though I first install it through a plugin manager. My current choice is VAM, but there're others like Vundle and Pathogen.
Try this method:
for plugin in plugins
try
install plugin
read doc
test plugin
catch
remove plugin
endtry
endfor
Also, make sure you read and understand :h ins-completion before hunting down plugins.

Autocompletion in Vim

I'm having trouble with autocompletion. How can I get a code suggestion while I'm typing?
I usually develop in PHP, Ruby, HTML, C and CSS.
Use Ctrl-N to get a list of word suggestions while in insert mode. Type :help i_CTRL-N to see Vim's documentation on this functionality.
Here is an example of importing the Python dictionary into Vim.
You can use a plugin like AutoComplPop to get automatic code completion as you type.
2015 Edit: I personally use YouCompleteMe now.
If you are using VIM version 8+, just type Ctrl + n or Ctrl + p.
You can start from built-in omnifunc setting.
Just put:
filetype plugin on
au FileType php setl ofu=phpcomplete#CompletePHP
au FileType ruby,eruby setl ofu=rubycomplete#Complete
au FileType html,xhtml setl ofu=htmlcomplete#CompleteTags
au FileType c setl ofu=ccomplete#CompleteCpp
au FileType css setl ofu=csscomplete#CompleteCSS
on the bottom of your .vimrc, then type <Ctrl-X><Ctrl-O> in insert mode.
I always rely on this CSS completion.
There is also https://github.com/Valloric/YouCompleteMe and it includes things like Jedi and also has fuzzy match. So far I found YCM to be the fastest among what I have tried.
Edit: There also exists some new ones like https://github.com/maralla/completor.vim
Another option is coc.nvim.
It's really fast and the completion is great as it uses intellisense the same autocompletion as VScode has.
It also has linting capabilities. So it shows you were you might have a bug.
It supports a multitude of languages.
It might take a bit to set up and configure but I think it is the best autocompletion engine for vim out there.
I've used neocomplcache for about half a year. It is a plugin that collects a cache of words in all your buffers and then provides them for you to auto-complete with.
There is an array of screenshots on the project page in the previous link. Neocomplcache also has a ton of configuration options, of which there are basic examples on the project page as well.
If you need more depth, you can look at the relevant section in my vimrc - just search for the word neocomplcache.
Here is link! for PHP.
press the Ctrl + x followed by Ctrl + o keys while writing some PHP functions.
Thanks to Oseems Solutions for the tutorial
If you only wanna auto-completion from cache of your current buffers, supertab is easier to install than neocomplete, can work on Mac pre-installed vim out of box without the need of MacVim.
You can check other alternatives at vim awesome.
For PHP, Padawan with Deoplete are great solutions for having a robust PHP autocompletion in Neovim. I tried a lot of things and Padawan work like a charm!
For Vim you can use Neocomplete instead of Deoplete.
I wrote an article how to make a Vim PHP IDE if somebody is interested. Of course Padawan is part of it.
I recently discovered a project called OniVim, which is an electron-based front-end for NeoVim that comes with very nice autocomplete for several languages out of the box, and since it's basically just a wrapper around NeoVim, you have the full power of vim at your disposal if the GUI doesn't meet your needs. It's still in early development, but it is rapidly improving and there is a really active community around it. I have been using vim for over 10 years and started giving Oni a test drive a few weeks ago, and while it does have some bugs here and there it hasn't gotten in my way. I would strongly recommend it to new vim users who are still getting their vim-fingers!
OniVim: https://www.onivim.io/

Resources