How to Install and Use Vim on Ubuntu: Complete Beginner’s Guide to Setup, Japanese Input, and Plugins

1. Introduction

The Importance of Vim on Ubuntu

Vim is one of the most essential text editors for Ubuntu and other Linux distributions.
As its name “Vim (Vi IMproved)” suggests, it is an enhanced and extended version of the traditional “vi” editor, offering fast operation and highly flexible customization.
Because Vim is widely used for tasks like server management and programming in Linux environments, mastering Vim gives Ubuntu users a significant advantage.

Benefits of Using Vim

There are many advantages to installing and using Vim on Ubuntu.
Here are the key points:

  • Lightweight and Fast: Launches instantly and works smoothly even on low-spec systems.
  • Highly Customizable: You can build your ideal editor environment by editing the configuration file (.vimrc).
  • Optimized for Keyboard Use: You can do everything with just the keyboard—no mouse needed—greatly boosting productivity.
  • Extensible via Plugins: Easily add features to customize Vim to fit your workflow.

Purpose and Structure of This Article

This article aims to help you install and start using Vim on Ubuntu.
It covers not just the installation process but also basic settings, how to set up Japanese input, and troubleshooting—all explained step by step for beginners.

If you’re new to Vim on Ubuntu, follow along for a smooth start!

2. Installing Vim on Ubuntu

Check if Vim Is Already Installed

Some versions of Ubuntu come with a lightweight version called “vim-tiny” pre-installed.
First, open your terminal and run the following command to check if Vim is installed:

vim --version

If this command displays version info, Vim is present.
If you get an error or see a message about “vim-tiny,” it’s recommended to install the full version of Vim for full functionality.

How to Install Vim

On Ubuntu, you can easily install Vim using the standard package manager APT (Advanced Package Tool).
Follow these steps to get the latest version:

1. Update the Package List

First, update your package list to make sure you get the latest version.

sudo apt update

2. Install Vim

Next, install Vim itself.

sudo apt install vim

This command will automatically download and install the necessary packages.
When asked, “Do you want to continue? [Y/n]”, just press Y and hit Enter.

Check the Installed Vim Version

Once installed, check your Vim version again:

vim --version

This will show the installed version and build options (such as +clipboard).
If you see “+clipboard,” you can easily copy and paste between systems, making Vim even more useful.

Tip: Installing via GUI Software Center (For Beginners)

If you’re uncomfortable with terminal commands, you can also install Vim using Ubuntu Software (the GUI Software Center):

  1. Open “Ubuntu Software” from the applications list
  2. Type “Vim” into the search bar
  3. Select Vim and click the “Install” button

This method allows even Linux beginners to install Vim easily without using the terminal.

3. Basic Vim Settings

The Role and Creation of the .vimrc File

The .vimrc file is used to customize how Vim works.
By adding your settings to this file, they will automatically be applied when Vim starts, giving you a more comfortable environment.

Typically, .vimrc is located in your home directory (~/.vimrc).
If it doesn’t exist, create it with this command:

touch ~/.vimrc

Then, open it with Vim or your favorite editor:

vim ~/.vimrc

Recommended Basic Settings for Beginners

Here are some must-have settings if you’re new to Vim on Ubuntu:

Show Line Numbers

Seeing line numbers is very helpful when editing code or text.

set number

Enable Syntax Highlighting

To make your code easier to read, enable syntax-based color highlighting.

syntax on

Indentation Settings

Set the indentation width to 4 spaces for consistent formatting and better readability.

set tabstop=4
set shiftwidth=4
set expandtab

Ignore Case in Search

This setting makes searches case-insensitive by default.

set ignorecase
set smartcase

ignorecase always ignores case, while smartcase distinguishes only if uppercase letters are used in the search term.

Saving and Applying Settings

After editing your .vimrc, save and restart Vim to apply the settings.
Vim reads .vimrc on startup, so close and reopen it for changes to take effect.

Alternatively, you can reload the settings in an open Vim session with:

:source ~/.vimrc

This lets you apply changes instantly without restarting Vim—useful when experimenting with new settings.

4. Setting Up Japanese Input

Installing and Setting Up Japanese Input Method (IME)

To type Japanese in Vim, you need to have a Japanese input method (IME) properly installed on Ubuntu.
The most common IMEs are “fcitx-mozc” and “ibus-mozc.” Here are two popular ways to set them up:

Installing fcitx-mozc

fcitx is a lightweight and fast IME framework, popular among Ubuntu users.
Use these commands to install fcitx and the Mozc Japanese input engine:

sudo apt update
sudo apt install fcitx-mozc

After installing, change your keyboard input system to “fcitx” in System Settings under “Language Support.” Then log out and log back in to activate fcitx.

Installing ibus-mozc

If you use Ubuntu’s standard input system IBus, install Mozc with:

sudo apt update
sudo apt install ibus-mozc

After installing, go to System Settings > Region & Language > Input Sources, and add “Japanese (Mozc).” Setup is complete!

Tips for Japanese Input in Vim

Since Vim was originally developed for English environments, there are a few things to watch for with Japanese input.

IME Behavior by Vim Mode

Vim has “Normal Mode” and “Insert Mode.” Typically, you only need IME for Japanese input in Insert Mode.
If IME is on in Normal Mode, it may cause accidental command input—so try to switch IME depending on your Vim mode for better efficiency.

Vim and IME Compatibility Issues

Some Ubuntu setups may have trouble with IME in Vim.
Especially in terminal Vim, sometimes the Japanese conversion window won’t display properly.
In that case, try using the GUI version (gvim), or adjust your font and encoding settings.

Setting IME Switch Shortcuts

It’s helpful to assign shortcut keys to switch between Japanese and English input quickly.

If you use fcitx, set it up like this:

  1. Open the fcitx settings
  2. Select the “Global Config” tab
  3. Set “Switch Input Method On/Off” to your preferred key (e.g., Half-width/Full-width key)

This lets you toggle Japanese/English input instantly in Vim and other applications.

5. For an Even Better Vim Experience

Recommended Plugins

Vim is powerful out of the box, but plugins can make your experience even better.
Here are some top plugins for using Vim on Ubuntu:

vim-airline

vim-airline makes the status line beautiful and more informative.
See file names, line numbers, encoding, and more at a glance for better productivity.

To install:

Plug 'vim-airline/vim-airline'

See the plugin manager section below for installation details.

nerdtree

nerdtree adds a file tree inside Vim.
This makes it easy to visually navigate directories, just like in a GUI editor—great for large projects.

To install:

Plug 'preservim/nerdtree'

To open NERDTree, run:

:NERDTreeToggle

This opens the sidebar file tree.

How to Install a Plugin Manager (vim-plug)

If you use multiple plugins, a plugin manager is essential.
Here’s how to set up the popular “vim-plug”:

Installing vim-plug

  1. Download and place vim-plug:
curl -fLo ~/.vim/autoload/plug.vim --create-dirs   https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  1. Add your plugins to .vimrc:
call plug#begin('~/.vim/plugged')

Plug 'vim-airline/vim-airline'
Plug 'preservim/nerdtree'

call plug#end()
  1. Start Vim and run:
:PlugInstall

This will install your selected plugins automatically.

Smoother Cursor Movement When Typing Japanese

Sometimes, the cursor may lag or act unpredictably during Japanese input.
There are ways to improve this:

Automatically Toggle IME by Vim Mode

You can automatically switch IME on/off depending on Vim’s mode to prevent mistakes and ensure smooth Japanese input.
For example, the “fcitx.vim” plugin enables this.

Using skkeleton (for Neovim)

Neovim users can try the new “skkeleton” plugin for native Japanese input handling, resulting in a much more comfortable experience.

6. Troubleshooting

If Vim Won’t Start or Shows Errors

Sometimes, after installing Vim, you might see errors at startup or it may not launch at all.
Common causes include:

  • Missing dependency packages during installation
  • Mistakes in your .vimrc configuration file
  • Permission issues preventing files from loading

How to Fix

  1. First, re-check if Vim is properly installed:
vim --version
  1. If there are install issues, try uninstalling and reinstalling:
sudo apt remove vim
sudo apt install vim
  1. If your .vimrc has issues, you can start Vim while ignoring the config file:
vim -u NONE

If this works, check your .vimrc for errors.

If Japanese Input Doesn’t Work

Sometimes, Japanese input may not work on Ubuntu—not just in Vim, but system-wide.
In Vim, especially, IME integration can be tricky. Check the following:

  • Is your IME (fcitx/ibus) running properly?
  • Is Japanese input enabled in system settings?
  • Is your terminal’s font and encoding set up correctly?

If you can’t get it working in terminal Vim, try the GUI version (gvim) for better results.

If Settings Aren’t Applied

If changes in .vimrc aren’t showing up when you start Vim, check these points:

  1. Is .vimrc in the correct location (your home directory)?
  • Check: ~/.vimrc
  1. Is the file name correct?
  • It’s case sensitive: use .vimrc, not .Vimrc
  1. Any typos or mistakes in the file?
  • Even a small typo can break Vim commands—double-check syntax.
  1. Did you save and restart Vim?
  • Or reload instantly with:
:source ~/.vimrc

Following these steps will resolve most config issues.

7. Summary

Getting Started with Vim on Ubuntu: The Workflow

This guide covered how to install Vim on Ubuntu, set up basic configurations, configure Japanese input, add useful plugins, and troubleshoot common issues.

Here’s a quick step-by-step recap for getting started:

  1. Install Vim via Terminal or Ubuntu Software
  2. Create a .vimrc file and add basic settings like line numbers and syntax highlighting
  3. Set up Japanese input using fcitx-mozc or ibus-mozc
  4. Boost productivity with plugins like vim-airline and nerdtree
  5. If errors occur, troubleshoot step by step

By following these steps, even beginners can use Vim comfortably on Ubuntu.

Next Steps: Mastering Vim

This article is just the first step toward mastering Vim.
Vim’s deep customizability and powerful features mean the more you learn, the better you can make it fit your workflow.

For further learning, consider exploring:

  • Automating your setup with Vim script (VimL)
  • Setting up advanced development with LSP (Language Server Protocol)
  • Switching to Neovim and using its extra features
  • Optimizing writing in both Japanese and English

Enjoy building your perfect editor environment!

侍エンジニア塾