Skip to content

Instantly share code, notes, and snippets.

Last active December 23, 2022 06:14
Show Gist options
  • Save sts10/afd5e98d4724935b55163a0d89d58878 to your computer and use it in GitHub Desktop.
Save sts10/afd5e98d4724935b55163a0d89d58878 to your computer and use it in GitHub Desktop.
Basic Vim config file (vimrc) for Linux (2022)
set statusline=%f
set statusline+=\ %h%w%m%r
set statusline+=%=
set statusline+=%-16(\ %l/%L\%)%P
set statusline+=\ %P/%L
set statusline+=\
nnoremap <silent> gx :normal mxviugx<Esc>`x
nnoremap <silent> gX :call system('open ' . expand('%'))<CR>
set termguicolors
set guicursor=
set hidden
syntax on
set guifont=DejaVu\ Sans\ Mono:h20
set background=dark
set relativenumber
set number
set numberwidth=2
set scrolloff=5
set sidescrolloff=3
set laststatus=2
autocmd BufEnter * set mouse=
autocmd BufNewFile,BufReadPost .gitignore set filetype=text
autocmd BufNewFile,BufReadPost *.md set filetype=markdown
autocmd BufNewFile,BufReadPost *.csv set filetype=csv
autocmd BufEnter * if &filetype == "" | setlocal ft=markdown | endif
autocmd VimResized * wincmd =
set splitbelow splitright
set nowrap
autocmd FileType text setlocal wrap
autocmd FileType html setlocal wrap
autocmd FileType markdown setlocal wrap
autocmd FileType srt setlocal wrap
set linebreak
set sc
set lazyredraw
set ttyfast
set history=1000
set backspace=2
set expandtab
set tabstop=2
set shiftwidth=2
autocmd FileType sh,markdown,rust,python,zig setlocal tabstop=4
autocmd FileType sh,markdown,rust,python,zig setlocal shiftwidth=4
set autoindent
set smartindent
set breakindent
set wildmenu
set incsearch
set nohlsearch
set autoread
set ignorecase
set smartcase
set visualbell
filetype on
filetype plugin on
filetype indent on
set formatoptions+=j
autocmd FileType markdown setlocal spell spelllang=en_us
autocmd FileType srt setlocal spell spelllang=en_us
autocmd FileType markdown setlocal complete+=kspell
autocmd FileType srt setlocal complete+=kspell
nnoremap <S-Enter> o<Esc>
autocmd FileType html,markdown,text vnoremap <expr> j v:count ? 'j' : 'gj'
autocmd FileType html,markdown,text vnoremap <expr> k v:count ? 'k' : 'gk'
vnoremap . :norm.<CR>
autocmd FileType markdown vnoremap <c-a> <Esc>`<i[<Esc>`>la](<Esc>"+]pa)<Esc>
autocmd FileType markdown nnoremap gr mxgogogx`x
nnoremap D d$
nnoremap Y y$
nnoremap x "_x
nmap X "_d
nmap XX "_dd
vmap X "_d
vmap x "_d
nnoremap c "_c
vnoremap c "_c
nnoremap <Leader>p "+]p
nnoremap <Leader>P "+]P
nnoremap <Leader>y :y+<cr>
nnoremap <Leader>c ^"+c$
nnoremap <Leader>d ^"+d$
vnoremap <Leader>y "+y
vnoremap <Leader>c "+c
vnoremap <Leader>d "+d
nnoremap <Leader>a :%y+<cr>
nnoremap gV `[v`]
nnoremap <C-j> :m .+1<CR>==
nnoremap <C-k> :m .-2<CR>==
inoremap <C-j> <Esc>:m .+1<CR>==gi
inoremap <C-k> <Esc>:m .-2<CR>==gi
vnoremap <C-j> :m '>+1<CR>gv=gv
vnoremap <C-k> :m '<-2<CR>gv=gv
nnoremap <Right> <C-w>l
nnoremap <Left> <C-w>h
nnoremap <Up> <C-w>k
nnoremap <Down> <C-w>j
cnoremap <C-A> <Home>
cnoremap <C-E> <End>
cnoremap <C-B> <Left>
cnoremap <C-F> <Right>
Copy link

sts10 commented Dec 17, 2022

Hoping this will work with both Neovim and regular Vim... Haven't tested it much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment