Sieuwert Otterloo — Cape Canaveral, FL, USA

VIM for Java Developers

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”

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aymen Furter

Aymen Furter

DevOps – Linux — Kubernetes –Azure — Java — JS — Apache Camel