.vimrc config file

Published on Jun 13, 2024


Installation

1sh -c "$(curl -fsSL https://raw.githubusercontent.com/KazeTachinuu/config/master/installvim.sh)"

Configuration

  1  " Enable Vundle: Vim plugin manager
  2set rtp+=~/.vim/bundle/Vundle.vim
  3call vundle#begin()
  4
  5" Basic plugins
  6Plugin 'VundleVim/Vundle.vim'
  7Plugin 'scrooloose/nerdtree'       " File tree explorer with Ctrl+N
  8Plugin 'vim-airline/vim-airline'   " Stylish status bar
  9Plugin 'jiangmiao/auto-pairs'      " Automatic insertion of brackets, quotes, etc.
 10Plugin 'w0rp/ale'                  " Syntax checking and linting
 11Plugin 'honza/vim-snippets'        " Collection of useful snippets
 12Plugin 'garbas/vim-snipmate'       " Snippet management (deprecated, consider using UltiSnips or vim-snippets instead)
 13Plugin 'tomtom/tlib_vim'           " Required for some plugins
 14Plugin 'MarcWeber/vim-addon-mw-utils' " More utilities for Vim
 15Plugin 'sainnhe/sonokai'           " Beautiful colorscheme
 16Plugin 'rhysd/vim-clang-format'    " Auto-Format buffer on save
 17
 18call vundle#end()
 19
 20" INSTALL PLUGINS WITH :PluginInstall
 21
 22" Basic Behavior and Interface
 23set number              " Show line numbers
 24set wrap                " Wrap lines
 25set encoding=utf-8      " Use UTF-8 encoding
 26set mouse=a             " Enable mouse support
 27set wildmenu            " Visual autocomplete for command menu
 28set lazyredraw          " Redraw screen only when needed
 29set showmatch           " Highlight matching parentheses / brackets [{()}]
 30set laststatus=2        " Always show statusline
 31set ruler               " Show line and column number of the cursor
 32set signcolumn=yes      " Show sign column for LSP diagnostics
 33set clipboard=unnamedplus  " Use system clipboard
 34
 35" Key Bindings
 36nnoremap j gj           " Move down by visual line (don't skip wrapped lines)
 37nnoremap k gk           " Move up by visual line (don't skip wrapped lines)
 38nnoremap <C-d> <C-d>zz  " Scroll down half screen
 39nnoremap <C-u> <C-u>zz  " Scroll up half screen
 40nnoremap Q <nop>        " Disable Ex mode
 41nnoremap <C-a> ggVG     " Select all text
 42nnoremap <C-c> <cmd>%y<CR> " Copy all text
 43
 44vnoremap J :m '>+1<CR>gv=gv
 45vnoremap K :m '<-2<CR>gv=gv
 46
 47" Toggle NERDTree file tree
 48nnoremap <C-n> :NERDTreeToggle<CR>
 49
 50" Find and replace in all files with CTRL+S in normal mode
 51nnoremap <C-s> :%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>
 52
 53" Vim Appearance
 54try
 55  colorscheme sonokai     " Set colorscheme
 56catch /^Vim\%((\a\+)\)\=:E185/
 57  colorscheme default     " Fallback to default if sonokai not installed
 58endtry
 59
 60set termguicolors       " Enable true colors support
 61" autocmd vimenter * hi Normal guibg=NONE ctermbg=NONE  " Set background to transparent
 62
 63" Use filetype-based settings
 64syntax enable           " Enable syntax highlighting
 65filetype plugin indent on  " Enable filetype-specific plugins and indentation
 66
 67" Tab Settings
 68set tabstop=4           " Set tab width to 4 spaces
 69set expandtab           " Use spaces instead of <TAB>
 70set shiftwidth=4        " Number of spaces to use for (auto)indent
 71set softtabstop=4       " Backspace deletes up to 4 spaces
 72
 73" Search Settings
 74set incsearch           " Highlight matches as characters are entered
 75set hlsearch            " Highlight all matches
 76
 77" Turn off search highlighting with <CR> (carriage-return)
 78nnoremap <CR> :nohlsearch<CR><CR>
 79
 80" Miscellaneous Settings
 81set background=dark     " Use dark background
 82set autoread            " Autoread files changed outside Vim
 83set scrolloff=8         " Minimum lines to keep above/below cursor
 84set colorcolumn=80      " Highlight column 80
 85set hidden              " Allow hiding buffers with unsaved changes
 86set undofile            " Save undo history to file
 87set undodir=$HOME/.vimundo/  " Directory for undo files
 88set backspace=eol,start,indent  " Allow backspace in insert mode
 89set whichwrap+=<,>,h,l  " Allow <BS>, <Del>, etc. in insert mode
 90set lazyredraw          " Don't redraw while executing macros
 91set magic               " Enable magic in regular expressions
 92set showmatch           " Show matching brackets when text indicator is over them
 93
 94" Files, Backups, and Undo
 95set nobackup            " No backup files
 96set nowb                " No write backup files
 97set noswapfile          " No swap files
 98
 99let g:snipMate = { 'snippet_version' : 1 }
100nnoremap <SPACE> <Nop>
101let mapleader=" "
102set ph=10               " Max height of windows appearing
103
104let g:clang_format#auto_format=1
105
106