Skip to content

Instantly share code, notes, and snippets.

@hG3n
Last active December 22, 2023 16:37
Show Gist options
  • Save hG3n/7f7473d91109d8c060863f4c4ad5d686 to your computer and use it in GitHub Desktop.
Save hG3n/7f7473d91109d8c060863f4c4ad5d686 to your computer and use it in GitHub Desktop.
"""""""""""""""""""""""""""
"--- GENERAL SETTINGS ---"
"""""""""""""""""""""""""""
scriptencoding utf-8
set enc=utf-8
set fileencoding=utf-8
set fileencodings=ucs-bom,utf8,prc
set backspace=indent,eol,start "in case bcksp isnt working well"
set tabstop=2
set shiftwidth=2
set softtabstop=2 "set Tabvalue=4"dd
set ruler "always show actual position"
set nu "side indexnunbers"
set history=1000
set undolevels=1000
set noswapfile "disable creating stupid .swp files"
set nobackup
set nowritebackup
set autoindent
set title "sets filename on top of the open window"
set wildmenu "sets the autocomplete in commandline"
set showmode "shows the actual mode"
set mouse=a "enables Mouse in vim"
set clipboard=unnamed "use the system clipboard for copying and pasting
set showcmd "show partial commands in status line and
"selected characters/lines in visual mode"
set showmatch "show matching brackets/parenthesis
set incsearch "find as you type search"
set hlsearch "highlights searched objects"
set expandtab "set tabs to spaces
let mapleader = "," "creates mapleader do do more key combinations
let g:mapleader = ","
"clearing highlighted search
nmap <silent> <leader>/ :nohlsearch<CR>
"enables codefolding"
set foldmethod=indent
set foldnestmax=10
set foldcolumn=2
set nofoldenable
set foldlevel=1
"soft wrap and indent lines
set breakindent
set showbreak=\
" scroll down with five lines visible
set scrolloff=5
" show the numbers od lines
"set relativenumber
"enables syntax detection"
syntax on
"colorscheme"
set t_Co=256
" set to autoread if a file is changed from the outside
set autoread
""""""""""""""""""""
"--- REMAPPINGS ---"
""""""""""""""""""""
" options for key remapping
" <Esc> Escape key
" <C-G> CTRL-G
" <Up> cursor up key
" <C-LeftMouse> Control- left mouse click
" <S-F11> Shifted function key 11
" <M-a> Meta- a ('a' with bit 8 set)
" <M-A> Meta- A ('A' with bit 8 set)
" <t_kd> "kd" termcap entry (cursor down key)
" switch to insert mode when typing 'jk' in insert mode
" best map EVER
inoremap jk <esc>
" temporarily disable escape and cursor keys key
inoremap <esc> <nop>
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
" movement
nmap H 0
vmap H 0
nmap L $
vmap L $
"Stupid shift key fixes & helper"
cmap X x
cmap W w
cmap Q q
cmap WQ wq
cmap wQ wq
cmap Tabe tabe
cmap qq q!
cmap xx x!
cmap ww w!
" faster mapping to get into normal mode
vmap ; :norm
"Yank from the cursor to the end of the line, to be consistent with C and D"
nnoremap Y y$
"pane switching done easily
nmap <tab> <C-w><C-w>
"tab movement
nmap tn :tabnew<CR>
nmap tq :tabclose<CR>
nmap <S-tab> :tabnext<CR>
" cycle through buffers
nmap B :bnext<CR>
" center current search result
nmap n nzz
nmap N Nzz
"toggle tagbar
" nmap tb :Tagbar<CR>
"get the fuck out of insert mode if I press esc
"inoremap <Esc> <Esc><Esc>
"Sudo to write
cnoremap w!! w !sudo tee % >/dev/null
"return to the same line if reopen a file"
augroup line_return
au!
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ execute 'normal! g`"zvzz' |
\ endif
augroup END
"automatically add shebang in the first line of the file
augroup Shebang
autocmd BufNewFile *.py 0put =\"#!/usr/bin/env python\<nl>\"|$
autocmd BufNewFile *.zsh 0put =\"#!/bin/bash <nl>\"|$
autocmd BufNewFile *.sh 0put =\"#!/bin/bash <nl>\"|$
augroup END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment