Last active
November 29, 2025 13:11
-
-
Save keyle/e37c31e0c465d6ae69bb5e8090063138 to your computer and use it in GitHub Desktop.
vimrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| syntax on | |
| filetype plugin indent on | |
| set tabstop=4 | |
| set shiftwidth=4 | |
| set expandtab | |
| set guioptions-=m | |
| set guioptions-=T | |
| set noesckeys | |
| set laststatus=2 | |
| set ruler | |
| set showmode | |
| set ttyfast | |
| set wildmenu | |
| set number | |
| set encoding=utf-8 | |
| "set visualbell | |
| set scrolloff=8 | |
| set ignorecase | |
| set smartcase | |
| set incsearch | |
| set cinoptions=l1 | |
| set modeline | |
| set iminsert=0 | |
| set imsearch=0 | |
| set noswapfile | |
| set nobackup | |
| set nowritebackup | |
| set virtualedit=onemore " or onemore or all for past end of line | |
| set background=dark | |
| " bad colour schemes need a dark one to start | |
| " colorscheme habamax | |
| " colorscheme austere | |
| colorscheme lunaperche | |
| if &term =~ "xterm\\|rxvt" | |
| let &t_SI = "\<Esc>]12;yellow\x7" " Insert mode color | |
| let &t_EI = "\<Esc>]12;gray\x7" " Normal mode color | |
| endif | |
| autocmd BufEnter * if &filetype == "go" | setlocal noexpandtab | |
| nnoremap <c-z> <nop> | |
| " Always open quickfix/location list small after a search | |
| augroup qf_auto_open | autocmd! | |
| autocmd QuickFixCmdPost [^l]* botright copen 8 " :make, :grep, :vimgrep -> quickfix | |
| autocmd QuickFixCmdPost l* botright lopen 8 " :lgrep, :lvimgrep -> location list | |
| augroup END | |
| " Don't comment following lines on enter | |
| augroup no_auto_comment | |
| autocmd! | |
| autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o | |
| augroup END | |
| " F12 close all panels and return to normal | |
| nnoremap <F12> :cclose <bar> lclose <bar> pclose <bar> helpclose <bar> wincmd p<CR> | |
| " Allow arrow keys in Insert | |
| set nocompatible | |
| set esckeys | |
| set ttimeout | |
| set ttimeoutlen=10 | |
| " Use ripgrep for :grep | |
| set grepprg=rg\ --vimgrep\ --hidden\ --smart-case\ --glob\ '!.git' | |
| set grepformat=%f:%l:%c:%m | |
| highlight StatusLine ctermfg=darkgray ctermbg=black guifg=#000000 guibg=#808080 | |
| " clangd parens complains is wrong | |
| hi cErrInParen ctermbg=NONE guibg=NONE guifg=NONE ctermfg=NONE | |
| " Move line/selection with Alt+Up/Down | |
| " Normal mode | |
| nnoremap <A-Up> :m .-2<CR>== | |
| nnoremap <A-Down> :m .+1<CR>== | |
| " Visual mode | |
| vnoremap <A-Up> :m '<-2<CR>gv=gv | |
| vnoremap <A-Down> :m '>+1<CR>gv=gv | |
| " Insert mode | |
| inoremap <A-Up> <Esc>:m .-2<CR>==gi | |
| inoremap <A-Down> <Esc>:m .+1<CR>==gi | |
| " all yanks/puts use the OS clipboard | |
| set clipboard+=unnamedplus | |
| " Map F3 to :grep | |
| nnoremap <F3> :grep<Space> | |
| " Sft-F3: open a vertical split on the left, then start :grep prompt | |
| nnoremap <S-F3> :leftabove vsplit \| wincmd l \| grep<Space> | |
| " make dd and d not yank | |
| nnoremap dd "_dd | |
| vnoremap d "_d | |
| " keep y working as expected | |
| nnoremap yy "*yy | |
| vnoremap y "*y | |
| " F4 to next | |
| nnoremap <F4> :cnext<CR> | |
| nnoremap <S-F4> :cprev<CR> | |
| " no lsp | |
| nnoremap <C-G> :execute 'tag ' . expand('<cword>')<CR> | |
| " navigate to | |
| nnoremap <silent> <Plug>(navigate-to) :call fzf#run(fzf#wrap({ | |
| \ 'dir': getcwd(-1, -1), | |
| \ 'source': 'fd --type f --hidden --follow --strip-cwd-prefix --exclude .git', | |
| \ 'sink': 'e' | |
| \}))<CR> | |
| " cmd shift r open | |
| " ghostty: keybind = cmd+shift+r=text:\x1b[99R | |
| nnoremap <silent> <Esc>[99R <Plug>(navigate-to) | |
| nnoremap <silent> <F1> <Plug>(navigate-to) | |
| " plugins :PlugInstall | |
| call plug#begin('~/.vim/plugged') | |
| Plug 'dart-lang/dart-vim-plugin' | |
| Plug 'natebosch/vim-lsc' | |
| Plug 'junegunn/fzf' | |
| Plug 'junegunn/fzf.vim' | |
| Plug 'mg979/vim-visual-multi' | |
| Plug 'tpope/vim-commentary' | |
| call plug#end() | |
| " vim-lsc | |
| let g:lsc_server_commands = { | |
| \ 'dart': 'dart language-server --protocol=lsp --client-id vim-lsc --client-version 1', | |
| \ 'c': 'clangd --log=error', | |
| \ 'cpp': 'clangd --log=error', | |
| \ 'go': {'command': 'gopls -remote=auto', 'log_level': -1, 'suppress_stderr': v:true } } | |
| let g:lsc_auto_map = v:true | |
| " Make Shift+U do redo in Normal mode | |
| nnoremap U <C-r> | |
| " Make Ctrl+R trigger LSP rename in Normal mode | |
| nnoremap <C-r> :LSClientRename<CR> | |
| let g:lsc_auto_map = { | |
| \ 'GoToDefinition': 'gd', | |
| \ 'GoToDefinitionSplit': 'gD', | |
| \ 'FindReferences': 'gr', | |
| \ 'NextReference': 'gR', | |
| \ 'PreviousReference': 'gP', | |
| \ 'FindImplementations': 'gi', | |
| \ 'FindCodeActions': '<C-p>', | |
| \ 'Rename': '<C-r>', | |
| \ 'ShowHover': '<C-k>', | |
| \ 'DocumentSymbol': 'go', | |
| \ 'WorkspaceSymbol': 'gS', | |
| \ 'SignatureHelp': 'gm', | |
| \ 'Completion': 'completefunc', | |
| \} | |
| let g:lsc_enable_popup_documentation = v:false | |
| set completeopt-=preview | |
| autocmd CompleteDone * pclose | |
| " vim-lsc: jump to next diagnostic | |
| nnoremap <silent> <F8> :lafter<CR> | |
| nnoremap <silent> <S-F8> :lbefore<CR> | |
| " Formatting | |
| " Use the CLI formatter - do not use it does not respect the width given | |
| " ghostty: keybind = super+e=text:\x1b[99E" | |
| nnoremap <silent> <ESC>[99E :!dart format --line-length 150 %<CR>:e<CR> | |
| " Make Ctrl+S save | |
| nnoremap <C-s> :w<CR> | |
| inoremap <C-s> <Esc>:w<CR>a | |
| vnoremap <C-s> <Esc>:w<CR>gv | |
| " Bind Ctrl+Q to quit Vim | |
| nnoremap <C-q> :qa<CR> | |
| inoremap <C-q> <Esc>:qa<CR> | |
| vnoremap <C-q> <Esc>:qa<CR> | |
| " Make copy to clipboard | |
| vnoremap <F2> "*yy | |
| " Enable mouse to set cursor position | |
| set mouse=a | |
| set ttymouse=sgr " modern terminals (Ghostty, iTerm2, Alacritty) | |
| " Optional: tweak click behavior | |
| set mousemodel=extend | |
| " F2 for multi cursor select | |
| let g:VM_maps = {} | |
| let g:VM_maps['Find Under'] = '<F2>' " add next occurrence, c to edit | |
| let g:VM_maps['Find Subword Under'] = '<S-F2>' | |
| " Reformat C/C++ on save via clang-format (no LSP needed) | |
| function! s:ClangFormatKeepView() abort | |
| let l:v = winsaveview() | |
| silent keepjumps keepmarks %!clang-format | |
| silent! undojoin | |
| call winrestview(l:v) | |
| endfunction | |
| augroup ClangFormatSave | |
| autocmd! | |
| autocmd BufWritePre *.c,*.cpp,*.h,*.hpp call <SID>ClangFormatKeepView() | |
| augroup END | |
| " Map Ctrl+E to clang-format | |
| nnoremap <silent> <C-e> :<C-u>call <SID>ClangFormatKeepView()<CR> | |
| vnoremap <silent> <C-e> :<C-u>silent keepjumps keepmarks '<,'>!clang-format<CR> | |
| inoremap <silent> <C-e> <Esc>:call <SID>ClangFormatKeepView()<CR>gi | |
| " Cursor line only in Insert mode, with custom background | |
| augroup InsertCursorLine | |
| autocmd! | |
| autocmd InsertEnter * setlocal cursorline | hi CursorLine guibg=#282c00 ctermbg=58 | |
| autocmd InsertLeave * setlocal nocursorline | hi CursorLine guibg=NONE ctermbg=NONE | |
| autocmd ColorScheme * hi CursorLine guibg=#282c00 ctermbg=58 | |
| augroup END |
Author
Author
MacVim ~/.gvimrc
set noswapfile
" set guifont=IBM\ Plex\ Mono:h18
set guifont=Myna:h22
" set guifont=Jetbrains\ Mono:h18
" set guifont=Berkeley\ Mono:h18
set clipboard=unnamedplus
nnoremap yy "+yy
" yellow block in Insert mode
hi InsertCursor gui=NONE guifg=black guibg=yellow
set guicursor=i:block-InsertCursor
" (optional) keep normal modes a block, others sane
set guicursor+=n-v-c:block,r-cr:hor20,o:hor50,ve:ver35,sm:block
" move line with cmd because alt can't work in macos textkit
nnoremap <D-Up> :m .-2<CR>==
nnoremap <D-Down> :m .+1<CR>==
vnoremap <D-Up> :m '<-2<CR>gv=gv
vnoremap <D-Down> :m '>+1<CR>gv=gv
inoremap <D-Up> <Esc>:m .-2<CR>==gi
inoremap <D-Down> <Esc>:m .+1<CR>==gi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If
plugis not installed, install it firstOpen
vimand:PlugInstallto SYNC PLUGINS.