Sieuwert Otterloo — Cape Canaveral, FL, USA

VIM for Java Developers

Aymen Furter
2 min readJul 15, 2020

In my everyday life as a developer, I use all kinds of different tools to perform various activities. I may use IntelliJ to develop Java-based apps, VIM to quickly edit a file (e.g. via k9s or directly via CLI) orSublime Text (mostly as a temporary buffer). I always hated to have multiple key bindings and philosophies to move around the code within these tools.

I believe this conflict is now solved for me. The solution is to use VIM as a primary way how to interact with text files. For all text editors.

The first step is to install neovim. Neovim is available in all major package managers of most distros (See details here: https://github.com/neovim/neovim/wiki/Installing-Neovim). So for Ubuntu it would be:

$ sudo apt-get install neovim

Since neovim can act as a drop-in replacement we can set it as a replacement for vim via set-alternative:

$ sudo update-alternatives — config vim

This will basically start neovim, whenever we use the vim command. This also works for third party tools like k9s.

For Sublime Text there is a very popular extension called “Vintage” which I strongly advice against using. For me the ActualVim extension worked much better. It actually will use neovim under the hood.

Fixing Copy/Paste

For copy/paste I wanted to have a single, system-wide clipboard. I achieved this by adding the following config to the file: .config/nvim/init.vim

au FileType xml exe ":silent %!xmllint --format --recover - 2>/dev/null":set clipboard=unnamedplus
" " Copy to clipboard
vnoremap <leader>y "+y
nnoremap <leader>Y "+yg_
nnoremap <leader>y "+y
nnoremap <leader>yy "+yy
" " Paste from clipboard
nnoremap <leader>p "+p
nnoremap <leader>P "+P
vnoremap <leader>p "+p
vnoremap <leader>P "+P

For IntelliJ I use the official IdeaVIM Plugin. I had to add the config below to ~/.ideavimrc to get the system wide copy/paste working:

“clipboard+=unnamed”

--

--

Aymen Furter
Aymen Furter

Written by Aymen Furter

I am a Cloud Solution Architect working for Microsoft. The views expressed on this site are mine alone and do not necessarily reflect the views of my employer.

No responses yet