Update docs/tech_docs/linux/vim.md

This commit is contained in:
2024-03-08 15:52:12 +00:00
parent c794bef8be
commit 5f9cf51460

View File

@@ -141,4 +141,121 @@ This `.vimrc` example includes essential configurations for a smooth and efficie
For each plugin listed (e.g., `vim-surround`, `nerdtree`, `fzf`), you would typically clone the plugin's repository into the specified directory or use a plugin manager like `vim-plug` to automate their installation and updates.
Remember, this is a starting point. As you grow more comfortable with Vim and your personal workflow evolves, you'll likely add, remove, or tweak these settings to better suit your needs.
Remember, this is a starting point. As you grow more comfortable with Vim and your personal workflow evolves, you'll likely add, remove, or tweak these settings to better suit your needs.
---
Enhancing your `.vimrc` file to support syntax highlighting for Python, JavaScript, Markdown, and Lua, alongside other quality-of-life improvements using Vim's built-in capabilities, is straightforward. Here's an updated section to include in your `.vimrc` file, focusing on syntax support and quality-of-life enhancements:
```bash
" Enhanced .vimrc Configuration for Syntax Support and Improvements
" ==============================================================================
" General Enhancements
" ==============================================================================
" Enable line numbers
set number
" Enable relative line numbers for easier text navigation
set relativenumber
" Enable syntax highlighting
syntax enable
" Show matching parentheses/brackets
set showmatch
" Automatically indent new lines
set autoindent
set smartindent
" Set search to be case insensitive unless capital letter is used
set ignorecase
set smartcase
" Enable mouse in all modes
set mouse=a
" Use 24-bit (true color) support
if exists('+termguicolors')
set termguicolors
endif
" Set command line height to 2 lines for more visibility
set cmdheight=2
" Show a visual indicator for lines that exceed a certain length (e.g., 80 characters)
set colorcolumn=80
" ==============================================================================
" Filetype-specific Enhancements
" ==============================================================================
" Enable filetype plugins
filetype plugin on
filetype indent on
" Syntax highlighting for Python, JavaScript, Markdown, Lua
au BufRead,BufNewFile *.py,*.js,*.md,*.lua setlocal syntax=on
" For Python: Set tab space
autocmd FileType python setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab
" For JavaScript: Set tab space
autocmd FileType javascript setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab
" For Markdown: Enable spell checking and wrap text
autocmd FileType markdown setlocal spell textwidth=80 wrap
" For Lua: Set tab space
autocmd FileType lua setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab
" ==============================================================================
" Additional Quality-of-Life Improvements
" ==============================================================================
" Use incremental search
set incsearch
" Highlight search results
set hlsearch
" Map <leader> to a space (or your preferred leader key)
let mapleader=" "
" Disable creating backup files
set nobackup
set nowritebackup
" Disable swap files
set noswapfile
" Open new split panes to right and bottom, which feels more natural
set splitbelow
set splitright
" Enable clipboard to use system clipboard
set clipboard=unnamedplus
" Quiet startup
set shortmess+=I
" ==============================================================================
" Custom Key Bindings for Improved Navigation and Editing
" ==============================================================================
" Map <leader>w to save the current file
nnoremap <leader>w :w<CR>
" Map <leader>q to quit
nnoremap <leader>q :q<CR>
" ==============================================================================
" End of Enhancements
" ==============================================================================
```
This enhanced `.vimrc` configuration focuses on leveraging Vim's built-in features to improve the editing experience for Python, JavaScript, Markdown, and Lua, as well as general quality-of-life improvements. It sets up syntax highlighting, adjusts indentation and tab spaces according to common conventions for each language, enables spell checking for Markdown, and includes several navigation and editing conveniences.
Keep in mind, while this setup uses Vim's built-in capabilities, exploring additional plugins can further extend functionality. However, as requested, this guide focuses on what can be achieved without external tools.