Skip to content

Instantly share code, notes, and snippets.

@ruph
Last active April 25, 2024 16:02
Show Gist options
  • Star 45 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save ruph/1437650 to your computer and use it in GitHub Desktop.
Save ruph/1437650 to your computer and use it in GitHub Desktop.
vim settings
" Use vim settings, rather then vi settings (much better!)
" This must be first, because it changes other options as a side effect.
set nocompatible
set t_Co=256 " iTerm2 supports 256 color mode.
set ai " auto indenting
set history=100 " keep 100 lines of history
set ruler " show the cursor position
syntax on " syntax highlighting
filetype plugin on " use the file type plugins
set showmode " always show what mode we're currently editing in
set tabstop=4 " a tab is four spaces
set softtabstop=4 " when hitting <BS>, pretend like a tab is removed, even if spaces
set noexpandtab " don't expand tabs to spaces by default
set shiftwidth=4 " number of spaces to use for autoindenting
set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
set backspace=indent,eol,start " allow backspacing over everything in insert mode
set autoindent " always set autoindenting on
set copyindent " copy the previous indentation on autoindenting
set showmatch " set show matching parenthesis
set smarttab " insert tabs on the start of a line according to
" shiftwidth, not tabstop
set scrolloff=4 " keep 4 lines off the edges of the screen when scrolling
set hlsearch " highlight search terms
set incsearch " show search matches as you type
" white space characters
set nolist
set listchars=eol:$,tab:.\ ,trail:.,extends:>,precedes:<,nbsp:_
highlight SpecialKey term=standout ctermfg=darkgray guifg=darkgray
" display white space characters with F3
nnoremap <F3> :set list! list?<CR>
" no indent on paste
set pastetoggle=<F2>
nnoremap <F2> :set invpaste paste?<CR>
set pastetoggle=<F2>
set showmode
"set mouse=a " enable using the mouse if terminal emulator supports it
" turned off - it kills copy/paste
" CTRL-down/up skips a paragraph.. like in emacs :)
:nmap <C-UP> {
:nmap <C-DOWN> }
" Jump words with alt
:map! <A-LEFT> <S-LEFT>
:map <A-LEFT> <S-LEFT>
:map! <A-RIGHT> <S-RIGHT>
:map <A-RIGHT> <S-RIGHT>
" Map alt-backspace to delete the previous word
:imap <M-BS> <C-w>
:nmap <M-BS> db
" Editor layout
set termencoding=utf-8
set encoding=utf-8
set lazyredraw " don't update the display while executing macros
set laststatus=2 " tell VIM to always put a status line in, even
" if there is only one window
set cmdheight=1 " use a status bar that is 1 rows high
" Behaviour
set history=1000 " remember more commands and search history
set undolevels=1000 " use many muchos levels of undo
if v:version >= 730
set undofile " keep a persistent backup file
set undodir=~/.vim/.undo,~/tmp,/tmp
endif
set nobackup " do not keep backup files, it's 70's style cluttering
set noswapfile " do not write annoying intermediate swap files,
" who did ever restore from swap files anyway?
set directory=~/.vim/.tmp,~/tmp,/tmp
" store swap files in one of these directories
" (in case swapfile is ever turned on)
set viminfo='20,\"80 " read/write a .viminfo file, don't store more
" than 80 lines of registers
set wildmenu " make tab completion for files/buffers act like bash
set wildmode=list:full " show a list when pressing tab and complete
" first full match
set wildignore=*.swp,*.bak,*.pyc,*.class
set title " change the terminal's title
set visualbell " don't beep
set noerrorbells " don't beep
set showcmd " show (partial) command in the last line of the screen
" this also shows visual selection info
set nomodeline " disable mode lines (security measure)
set background=dark " shell is usally dark
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if ! exists("g:leave_my_cursor_position_alone") |
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif |
\ endif
@josemdiaza
Copy link

Thanks!

@marobo
Copy link

marobo commented Sep 14, 2019

Nice!

@ramrasi
Copy link

ramrasi commented Apr 21, 2020

Thanks

@faustaleonardo
Copy link

Wonderful thanks

@dudhaniss
Copy link

Thanks !

@hharieta
Copy link

🥇

@BeauBryanDev
Copy link

Thank You AS well.

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