This guide explains the purpose of each setting in the provided Vim configuration. This configuration enhances the editing experience in Vim by setting up an environment that supports better navigation, visual aids, and usability features.
filetype plugin on: This command tells Vim to enable detection of the file type and to load the appropriate plugins and indentation rules for that file type. This enables custom behavior based on the type of file you are editing, which is very useful when working with different programming languages or file formats. For example, if you open a Python file, Vim can automatically load Python-specific indentation rules and plugins that improve coding in Python.syntax on: Enables syntax highlighting in Vim. This feature automatically applies color schemes to text based on the syntax of the programming language or content type you are editing, improving readability and making it easier to identify errors, keywords, and other elements of the code.set number: Enables line numbering on the left side of the window, which is useful for reference and navigation.set relativenumber: Displays the line numbers relative to the line with the cursor. This is useful for quickly moving among nearby lines.set autoindent: Automatically indents new lines to match the indentation level of the previous line.set smartindent: Makes indentation smart, useful for coding with proper alignment according to syntax.set tabstop=4: Sets the number of spaces that a tab character represents. Here it is set to 4 spaces.set shiftwidth=4: Sets the number of spaces to use for each step of (auto)indent. Here it is set to 4 spaces.set expandtab: Converts tabs into spaces. This ensures consistency in the file's formatting.set wrap: Allows long lines to wrap to the next line.set showcmd: Displays the command you are typing in the bottom right of the window.set ruler: Shows the cursor position at all times in the status line.set cursorline: Highlights the current line where the cursor is located.set mouse=a: Enables mouse support in all modes (normal, visual, insert, and command-line). Useful for scrolling and resizing windows.set hlsearch: Highlights all matches of search patterns.set ignorecase: Makes searches case-insensitive, allowing for easier text searching.set smartcase: Overridesignorecaseif the search pattern contains uppercase letters, making searches smarter.set incsearch: Shows incremental search results as you type.
<F4>: Toggles both absolute and relative line numbering on or off. This key binding allows you to quickly switch the visibility of line numbers, enabling a cleaner view when needed and providing detailed line references when working on editing or navigating through the document. This toggle is particularly useful for reducing visual clutter during comprehensive reading or editing sessions, while still offering the option to view line numbers for precise code referencing and navigation.<F5>: Disables mouse support, restoring the right-click context menu for copy-pasting using the mouse.<F6>: Re-enables mouse support, useful for navigating files and resizing panes.
- These settings are generally supported by default in Vim. However, some features like
smartindentmay behave differently based on other Vim plugins or scripts that are installed.
Enabling mouse support with set mouse=a can interfere with the terminal's ability to use the normal right-click context menu. This is particularly relevant for copying and pasting text. Use the <F5> and <F6> key bindings to toggle mouse support off and on when you need to use the context menu for copy-pasting.
These settings aim to provide a powerful and efficient editing environment in Vim, especially for programming and text editing. Adjust these settings according to your workflow and environment requirements.
This setup allows for user to use mouse as well as sets the F2 key to turn on / off the line numbers which makes it easier when you need to copy from vim.