diff --git a/README.md b/README.md index a739614..4fa0c0e 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,71 @@ -## Custom vim configuration - -``` -runtime! archlinux.vim " Run plugin archlinux.vim in Vim -set number " display line numbers -syntax on " enable syntax highlighting -set showmatch " highlight matching [{( characters -set textwidth=79 " set maximum text width to 79 characters -set nowrap " disable line wrapping -set mouse=r " enable mouse support in the terminal -set incsearch " enable incremental search -set nu " shortcut for number -set ts=4 " set tabstop to 4 spaces -set sw=4 " set shiftwidth to 4 spaces -set autoindent " enable autoindentation -``` +# Vim Configuration + +This repository contains a custom Vim configuration designed to enhance usability, provide flexible indentation settings for various file types, and improve the overall coding experience. + +## Features + +- **Search and Encoding**: + - Highlights all matches in search results. + - Ignores case in search patterns (`ignorecase`). + - Sets file encoding to UTF-8. + - Disables incremental search (`noincsearch`). + +- **Mouse Support**: + - Enables mouse functionality if available. + +- **Filetype-Specific Indentation**: + - HTML: 2 spaces for tabs and indentation. + - Python: 4 spaces for tabs and indentation. + - YAML: 2 spaces for tabs and indentation with custom indent keys. + +- **Autocommands**: + - Exits Insert mode if idle for a defined period. + - Automatically applies filetype-specific indentation. + +- **Status Line**: + - Displays file information, working directory, and cursor position. + +## Configuration Details + +```vim +syntax on +filetype plugin indent on + +" Search and encoding settings +set noincsearch " Disables incremental search +set ignorecase " Ignores case in search patterns +set encoding=utf8 " Sets file encoding to UTF-8 +set laststatus=2 " Always display the status line +set hlsearch " Highlights all matches in search results +set showmatch " Highlights matching parenthesis/brackets + +" Mouse support +if has("mouse") + set mouse=v " Enables mouse support in visual mode +endif + +" Filetype-specific indentation +function HtmlConfig() + set tabstop=2 softtabstop=2 expandtab shiftwidth=2 +endfunction + +function PythonConfig() + set tabstop=4 softtabstop=4 expandtab shiftwidth=4 +endfunction + +function YamlConfig() + set tabstop=2 softtabstop=2 expandtab shiftwidth=2 + set indentkeys-=0# indentkeys-=<:> +endfunction + +" Autocommands +autocmd CursorHoldI * stopinsert " Exit Insert mode if idle +autocmd FileType html call HtmlConfig() +autocmd FileType python call PythonConfig() +autocmd FileType yaml,yml call YamlConfig() + +" Status line +set statusline=\ File:\ %F%m%r%h\ %w\ \ Working\ Directory:\ %r%{getcwd()}%h\ -\ Line:\ %l\ -\ Column:\ %c + +" Prevent defaults.vim from overwriting these settings +let g:skip_defaults_vim = 1 diff --git a/etc/vimrc b/etc/vimrc index 0b406da..b89fb04 100755 --- a/etc/vimrc +++ b/etc/vimrc @@ -1,14 +1,47 @@ -" Custom vim configuration - -runtime! archlinux.vim " Run plugin archlinux.vim in Vim -set number " display line numbers -syntax on " enable syntax highlighting -set showmatch " highlight matching [{( characters -set textwidth=79 " set maximum text width to 79 characters -set nowrap " disable line wrapping -set mouse=r " enable mouse support in the terminal -set incsearch " enable incremental search -set nu " shortcut for number -set ts=4 " set tabstop to 4 spaces -set sw=4 " set shiftwidth to 4 spaces -set autoindent " enable autoindentation +syntax on +filetype plugin indent on + +" Search and encoding settings +set noincsearch " Disables incremental search; highlights only on Enter +set ignorecase " Ignores case in search patterns +set encoding=utf8 " Sets file encoding to UTF-8 +set laststatus=2 " Always display the status line at the bottom +set hlsearch " Highlights all matches in search results +set showmatch + +" Enables mouse support if available +if has("mouse") + set mouse=v +endif + + +" Configures indentation settings specifically for HTML files +function HtmlConfig() + set tabstop=2 softtabstop=2 expandtab shiftwidth=2 + " Sets tab, soft tab, and indentation width to 2 spaces for HTML files +endfunction + +" Configures indentation settings specifically for Python files +function PythonConfig() + set tabstop=4 softtabstop=4 expandtab shiftwidth=4 + " Sets tab, soft tab, and indentation width to 4 spaces for Python files +endfunction + +" Configures indentation settings specifically for YAML files +function YamlConfig() + set tabstop=2 softtabstop=2 expandtab shiftwidth=2 indentkeys-=0# indentkeys-=<:> + " Sets tab, soft tab, and indentation width to 2 spaces for YAML files, + " with custom indent keys +endfunction + +" Autocommands for automatic behavior +autocmd CursorHoldI * stopinsert " Exits Insert mode if cursor is idle for updatetime duration +autocmd FileType html call HtmlConfig() " Applies HtmlConfig() for HTML files +autocmd FileType python call PythonConfig() " Applies PythonConfig() for Python files +autocmd FileType yaml,yml call YamlConfig() " Applies YamlConfig() for YAML files + +" Status line configuration to show paste mode status, file information, working directory, +" and cursor position details +set statusline=\ File:\ %F%m%r%h\ %w\ \ Working\ Directory:\ %r%{getcwd()}%h\ -\ Line:\ %l\ -\ Column:\ %c +" Prevents defaults.vim from overwriting these settings +let g:skip_defaults_vim = 1