A simple Vim plugin that lets you insert single characters without leaving normal mode.
Find a file
lohhiiccc de7d77d1b4 feature: Add begin/end line singlechar insertion and static cursor option
- Introduce InsertCharBegin and InsertCharEnd commands
to insert a character at the beginning or end of the line (<Leader>I and <Leader>A).
- Add configuration variables for customizable mappings:
 - g:singlechar_map_insert_begin
 - g:singlechar_map_insert_end
- Implement GetInsertCommand() and DoSingleChar() in autoload/singlechar.vim
to support new modes and static cursor feature.
- Add g:singlechar_static_cursor option:
    when enabled, cursor returns to its original position after insertion.
2025-08-21 16:13:10 +02:00
autoload feature: Add begin/end line singlechar insertion and static cursor option 2025-08-21 16:13:10 +02:00
doc doc: update docs 2025-08-19 16:45:17 +02:00
plugin feature: Add begin/end line singlechar insertion and static cursor option 2025-08-21 16:13:10 +02:00
LICENSE Initial commit 2025-08-06 19:49:37 +02:00
README.md typo: strange and unnecessary "call" and fake news in README 2025-08-19 16:54:39 +02:00

vim-singlechar

A simple Vim plugin that lets you insert single characters (including Unicode) without leaving normal mode.

Overview

vim-singlechar allows you to quickly insert characters while staying in normal mode.

Features

  • Insert characters (supports Unicode) at or after the cursor position
  • Support for counts to insert a character multiple times
  • Stay in normal mode for efficient editing
  • Minimal workflow interruption
  • Works with Vim 9+
  • Supports vim-repeat for . repeat functionality

Installation

Manual installation

cd /tmp
git clone https://github.com/lohhiiccc/vim-singlechar.git
mkdir -p ~/.vim/pack/plugins/start/
cp -r vim-singlechar ~/.vim/pack/plugins/start/
cd -

Optional: Install vim-repeat

For seamless repeat (.) support, install vim-repeat:

mkdir -p ~/.vim/pack/tpope/start
cd ~/.vim/pack/tpope/start
git clone https://tpope.io/vim/repeat.git

Usage

By default, the plugin provides two mappings:

  • <Leader>i - Insert a character at the cursor position
  • <Leader>a - Insert a character after the cursor position

After pressing the mapping, you'll see a prompt asking for the character to insert. Press any character and it will be inserted without entering insert mode.

With count

You can use a count before the mapping to insert the character multiple times:

  • 3<Leader>i, will insert three commas at the cursor position
  • 5<Leader>a. will insert five periods after the cursor position

Repeat last insert with .

If vim-repeat is installed, you can repeat the last character insertion with . in normal mode.

Configuration

You can customize the plugin by setting these variables in your vimrc:

" Change the mappings (before loading the plugin)
let g:singlechar_map_insert_at = '<Leader>i'     " Default
let g:singlechar_map_insert_after = '<Leader>a'  " Default

" Change the prompt message
let g:singlechar_prompt = 'Press the character to insert - Press Esc to cancel...'  " Default

" Disable default mappings (if you want to create your own)
let g:singlechar_no_mappings = 1

" Show warning if more than one character is entered (default: enabled)
let g:singlechar_keylen_warning = 1

" Customize the warning message (default: 'Only the first character will be taken: {char}')
let g:singlechar_warning_message = 'Only the first character will be taken: {char}'

Commands

The plugin provides these commands:

  • :InsertCharAt [count] - Insert a character at the cursor position
  • :InsertCharAfter [count] - Insert a character after the cursor position

License

MIT License