AQ

BlogProjects

vim setup

November 28, 2024 (3mo ago)

" Basic Settings
set number            " Show line numbers
set relativenumber    " Show relative line numbers
set cursorline        " Highlight the current line
set scrolloff=8       " Keep 8 lines visible above and below the cursor
set signcolumn=yes    " Always show the sign column

Explanation:

  • set number: Displays absolute line numbers, useful for referencing specific lines.
  • set relativenumber: Displays relative line numbers for easier navigation.
  • set cursorline: Highlights the line where the cursor is located for better visibility.
  • set scrolloff=8: Ensures the cursor stays surrounded by at least 8 lines of context.
  • set signcolumn=yes: Keeps the sign column always visible to prevent shifting text.

" Tabs and Indentation
set tabstop=4         " A tab is equal to 4 spaces
set shiftwidth=4      " Indent by 4 spaces
set expandtab         " Convert tabs to spaces
set autoindent        " Copy indent from the current line

Explanation:

  • set tabstop=4: Configures tabs to visually represent 4 spaces.
  • set shiftwidth=4: Determines the width of auto-indents.
  • set expandtab: Converts tabs into spaces to ensure consistency across environments.
  • set autoindent: Automatically copies indentation from the previous line for faster coding.

" Search Settings
set ignorecase        " Ignore case in searches
set smartcase         " Override ignorecase if uppercase is used
set hlsearch          " Highlight search results
set incsearch         " Show matches while typing

Explanation:

  • set ignorecase: Makes search case-insensitive by default.
  • set smartcase: Activates case-sensitive search if uppercase letters are present in the query.
  • set hlsearch: Highlights all search results for easy identification.
  • set incsearch: Displays search results incrementally as you type the search query.