Skip to content

Instantly share code, notes, and snippets.

@cmndrsp0ck
Created February 7, 2024 05:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmndrsp0ck/a185e65ab7b198086661a0ad92b60818 to your computer and use it in GitHub Desktop.
Save cmndrsp0ck/a185e65ab7b198086661a0ad92b60818 to your computer and use it in GitHub Desktop.
simple vimrc configuration - no plugins
syntax on
set relativenumber
set number
set tabstop=4
set shiftwidth=4
set expandtab
set smartindent
set autoindent
set hidden
set autoread
set showtabline=0 " No need for tabs to show since i use buffers
set laststatus=2 " always show mod'd statusline
set cursorline
set t_Co=256
set mouse=a
set nopaste
set incsearch " move to match as you type the search query
set hlsearch " disable search result highlighting
" Set the leader button
let mapleader = ' '
" Set the cursor to a single line in Insert mode
" autocmd InsertEnter * set cursorline
" autocmd InsertLeave * set nocursorline
"----------------------------
" BEGIN CUSTOM FUNCTIONS
"----------------------------
" function for pastetoggle
fun! TogglePT()
if &paste == 0
set paste
else
set nopaste
endif
endfun
nnoremap <leader>pt :call TogglePT()<cr>
" function for line number
fun! ToggleLN()
if &number == 1
set nonumber
else
set number
endif
endfun
nnoremap <leader>ln :call ToggleLN()<cr>
" function for colorcolumn
fun! ToggleCC()
if &cc == ''
set cc=80
else
set cc=
endif
endfun
nnoremap <leader>cc :call ToggleCC()<cr>
" Toggle Line wrap
fun! ToggleWrap()
if &wrap == 0
set wrap
else
set nowrap
endif
endfun
nnoremap <leader>tw :call ToggleWrap()<cr>
" Function to generate a list of open buffer names
function! ListBuffers()
let buffer_list = []
for i in range(1, bufnr('$'))
if buflisted(i)
let bufname = bufname(i)
let current_buf = i == bufnr('%') ? '* ' : ' '
let buffer_list += [bufname . current_buf]
endif
endfor
return join(buffer_list, ' | ')
endfunction
" Customize the statusline to include the list of open buffers
set statusline+=%{ListBuffers()}
"----------------------------------------------
" Navigation
"----------------------------------------------
" Move between buffers with Shift + H or L
nnoremap <S-h> :bprevious<cr>
nnoremap <S-l> :bnext<cr>
"----------------------------------------------
" Splits
"----------------------------------------------
" Create horizontal splits below the current window
set splitbelow
set splitright
" Creating splits
nnoremap <leader>v :vsplit<cr>
nnoremap <leader>h :split<cr>
" Resize Vim windows with Ctrl + arrow keys
nnoremap <C-Left> :vertical resize -5<CR>
nnoremap <C-Right> :vertical resize +5<CR>
nnoremap <C-Up> :resize -5<CR>
nnoremap <C-Down> :resize +5<CR>
" Closing splits
nnoremap <leader>q :close<cr>
" Map leader key + e to open Lexplore
nmap <leader>e :20Lexplore<CR>
" prevents deleting lines when moving around with ctrl+arrow
set term=xterm
" remove trailing white space on save
augroup ws_clipper
autocmd BufWritePre * :%s/\s\+$//e
augroup END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment