LinuxCommandLibrary

nvim

Edit text files

TLDR

Open a file

$ nvim [path/to/file]
copy

Enter text editing mode (insert mode)
$ <Esc><i>
copy

Copy ("yank") or cut ("delete") the current line (paste it with

)

$ <Esc>[<y><y>|<d><d>]
copy

Enter normal mode and undo the last operation
$ <Esc><u>
copy

Search for a pattern in the file (press / to go to next/previous match)
$ <Esc></>[search_pattern]<Enter>
copy

Perform a regex substitution in the whole file
$ <Esc><:>%s/[regex]/[replacement]/g<Enter>
copy

Enter normal mode and save (write) the file, and quit
$ [<Esc><Z><Z>|<Esc><:>x<Enter>|<Esc><:>wq<Enter>]
copy

Quit without saving
$ <Esc><:>q!<Enter>
copy

SYNOPSIS

nvim [options] [file ...]
nvim -o[N] [file ...]
nvim -O[N] [file ...]
nvim -q [errorfile]
nvim -S [sessionfile]

PARAMETERS

-b
    Edits a file in binary mode.

-d
    Starts in diff mode, useful for comparing files.

-e
    Starts in Ex mode, for line-oriented editing.

-h, --help
    Displays a help message and exits.

-n
    Does not use a swap file, useful for temporary edits or slow network drives.

-o[N]
    Opens N windows horizontally, with N files if specified. Default is one window per file.

-O[N]
    Opens N windows vertically, similar to -o.

-R
    Starts in read-only mode, preventing accidental writes.

-S
    Restores the editor state from the specified session file.

-u
    Uses the specified file as the initialization file instead of the default init.lua.

--cmd
    Executes the given command before processing init.lua.

--headless
    Starts Neovim without a UI, useful for scripting or as a server.

--clean
    Starts Neovim with an empty configuration, ignoring user init.lua and plugins.

DESCRIPTION

nvim is a refactor of Vim, aiming to be more extensible, user-friendly, and maintainable. It's built on a strong foundation, inheriting Vim's powerful modal editing paradigm, which distinguishes between various modes (normal, insert, visual, etc.) for efficient text manipulation.

Key features of Neovim include an asynchronous job control API, allowing plugins to run tasks in the background without freezing the editor, and a remote plugin architecture. This enables plugins to be written in any language (Python, Node.js, Ruby, etc.) and communicate with Neovim over a MsgPack-RPC interface, significantly expanding its capabilities and the plugin ecosystem.

Neovim also provides a built-in terminal emulator, a powerful configuration system often utilizing Lua for its modern plugin ecosystem, and improved default settings. It aims to accelerate innovation in the Vim ecosystem by improving the core and providing a robust API for developers. While retaining strong compatibility with Vim's configuration and features, Neovim often feels faster and more responsive, especially with complex setups or large files, making it a popular choice for developers and power users.

CAVEATS

Neovim, like its predecessor Vim, has a steep learning curve for users new to modal editing. Its powerful configuration, while highly flexible, often relies on Lua for advanced setups, requiring some familiarity with the language.
While striving for Vim compatibility, some legacy Vim plugins or highly specific configurations might require minor adjustments to function optimally within the Neovim environment. Additionally, performance can be influenced by the quantity and complexity of loaded plugins.

LUA CONFIGURATION

Neovim strongly encourages and supports Lua for its configuration and plugin development, offering a more modern and powerful scripting alternative to Vimscript.

ASYNCHRONOUS JOB CONTROL

A core feature is the ability to run external commands and plugins asynchronously, preventing the editor from freezing during long-running tasks and improving responsiveness.

BUILT-IN TERMINAL EMULATOR

Neovim includes a powerful :terminal command, allowing users to run shell commands or interact with other tools directly within an editor buffer.

HISTORY

Neovim originated in 2014, conceived by Thiago de Moraes and successfully crowdfunded. The project's primary goal was to thoroughly refactor Vim's codebase to enable a more modern, extensible architecture. Key innovations included introducing an asynchronous job control API and a remote plugin architecture using MsgPack-RPC, which allowed plugins to be written in any language and run out-of-process. This addressed some of Vim's architectural limitations and significantly expanded its capabilities, fostering a vibrant new ecosystem of plugins and integrations. Its development has been community-driven, focusing on a stable, performant core while maintaining high compatibility with Vim's extensive feature set and configuration.

SEE ALSO

vim(1), vi(1), less(1), man(1), tmux(1)

Copied to clipboard