Skip to content

Instantly share code, notes, and snippets.

@faustind
Last active February 15, 2026 08:37
Show Gist options
  • Select an option

  • Save faustind/eb339bfa37a9c68371c31ecceb3dad2a to your computer and use it in GitHub Desktop.

Select an option

Save faustind/eb339bfa37a9c68371c31ecceb3dad2a to your computer and use it in GitHub Desktop.
Sensible vimrc for ssh machines
" --- General Settings ---
set nocompatible " Disable Vi compatibility to enable powerful Vim features
set encoding=utf-8 " Force UTF-8 encoding
filetype plugin indent on " Enable filetype detection, plugins, and indentation rules
syntax on " Enable syntax highlighting
" --- UI & Visuals ---
set number " Show line numbers
set ruler " Show cursor position (row, col) in status line
set showcmd " Show partial commands in the bottom right
set wildmenu " Enable visual autocomplete menu for command mode
set laststatus=2 " Always show the status line
set cursorline " Highlight the current line (improves visibility)
set scrolloff=5 " Keep 5 lines of context above/below cursor when scrolling
set t_Co=256 " specific to SSH: force 256 colors if terminal supports it
" --- Colors ---
try
colorscheme desert " 'desert' is a standard scheme available on almost all systems
catch
endtry
" --- Indentation (Standard 4-space) ---
set tabstop=4 " Width of a hard tab character
set shiftwidth=4 " Size of an indent
set softtabstop=4 " Number of spaces a tab counts for when editing
set expandtab " Convert tabs to spaces (safer for consistent rendering)
set autoindent " Copy indent from current line when starting a new one
set smartindent " Smarter indentation for C-like languages
" --- Search ---
set incsearch " Search as you type (incremental)
set hlsearch " Highlight all search matches
set ignorecase " Ignore case when searching...
set smartcase " ...unless you type a capital letter
" --- Behavior ---
set backspace=indent,eol,start " Make backspace work as expected over autoindent, line breaks, and start of insert
set history=1000 " increase command history limit
set autoread " Automatically reload files changed outside Vim
set nobackup " Prevent creation of backup files (~) to reduce clutter
set noswapfile " Prevent creation of swap files (.swp) - optional, use with care
" --- Key Mappings ---
let mapleader = "," " Set Leader key to comma
" Press <Leader> + space to clear search highlighting
nnoremap <leader><space> :nohlsearch<CR>
" Quick save with <Leader>w
nnoremap <leader>w :w<CR>
" --- Dump Auto-Pairs (Native) ---
" 1. Auto-close brackets and quotes
inoremap ( ()<Left>
inoremap [ []<Left>
inoremap { {}<Left>
" inoremap " ""<Left>
" inoremap ' ''<Left>
" 2. Smart handling for Enter inside braces (optional but very useful)
" When you type {<Enter>, it expands to:
" {
" |
" }
inoremap {<CR> {<CR>}<Esc>ko
" 3. Allow typing over the closing bracket (Semi-Smart)
" This prevents getting "())" if you manually type the closing bracket.
" It checks if the next character is the closing bracket; if so, it just moves right.
inoremap <expr> ) strpart(getline('.'), col('.')-1, 1) == ")" ? "\<Right>" : ")"
inoremap <expr> ] strpart(getline('.'), col('.')-1, 1) == "]" ? "\<Right>" : "]"
inoremap <expr> } strpart(getline('.'), col('.')-1, 1) == "}" ? "\<Right>" : "}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment