Skip to content

Instantly share code, notes, and snippets.

@marz619
Created May 30, 2023 20:54
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 marz619/69086319ef70240cdae6ffe783e72858 to your computer and use it in GitHub Desktop.
Save marz619/69086319ef70240cdae6ffe783e72858 to your computer and use it in GitHub Desktop.
set nocompatible " Use Vim defaults (much better!)
set bs=2 " allow backspacing over everything in insert mode
set ai " always set autoindenting on
set backup " keep a backup file
set viminfo='20,\"50 " read/write a .viminfo file, don't store more
" than 50 lines of registers
set history=50 " keep 50 lines of command line history
" 000328 from article in Linux Journal, Apr 2000
set incsearch " searches as you enter the string!
set ignorecase " Ignore case in searching for matches set smartcase " Ignore case ONLY if all lower case srch str
" set scrolloff=2 " Keep at least 2 lines of context on screen
set wildmode=longest,list " TAB=file completion. TAB TAB=list'em!
" added 12/2/07
colorscheme desert
" 2000/01/09 " set mouse=a " Not supported?? 4/15/00
set ruler " show the cursor position all the time
set laststatus=2 " 2=always, 1=only if 2+ windows, 0=never
"set secure
set shm=a
set showcmd
set showmatch
set showmode
" set smartindent
set sw=4
set ttyfast
set wrap
autocmd FileType makefile,Makefile set tabstop=4 sw=8 nosmarttab noexpandtab
" 2000/05/24 From SVEN's vimrc file...
set dictionary=/usr/dict/words,/app/local/dict/americanxlg
" 2021/0/11 Paragraph Reformatting: gwip
" https://vim.fandom.com/wiki/Automatic_formatting_of_paragraphs
" Use "help auto-format" to get various options
set textwidth=70
" Don't use Ex mode, use Q for formatting
map Q gq
" Make p in Visual mode replace the selected text with the "" register.
vnoremap p <Esc>:let current_reg = @"<CR>gvdi<C-R>=current_reg<CR><Esc>
" 20220915 Causes fits in terminals
syntax off
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
" if &t_Co > 2 || has("gui_running")
" set syntax on
" set hlsearch
" endif
"-----------------------------------------------------------------
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" In text files, always limit the width of text to 78 characters
autocmd BufRead *.txt set tw=78
augroup cprog
" Remove all cprog autocommands
au!
" When starting to edit a file:
" For C and C++ files set formatting of comments and set C-indenting on.
" For other files switch it off.
" Don't change the order, it's important that the line with * comes first.
autocmd FileType * set formatoptions=tcql nocindent comments&
autocmd FileType c,cpp set formatoptions=croql cindent comments=sr:/*,mb:*,el:*/,://
" Added 11/25/00 autocmd FileType c,perl,python set sw=4 smarttab expandtab
"autocmd FileType python set sw=2 smarttab expandtab
autocmd FileType makefile,Makefile set ts=8 sw=8 nosmarttab noexpandtab
" Call a Perl script to (potentially) generate a starting file from a
" prototype file in the templates dir
autocmd BufNewFile * execute "0,0 !$HOME/.vim.templates/gen_proto.pl <afile>"
augroup END
augroup gzip
" Remove all gzip autocommands
au!
" Enable editing of gzipped files
" set binary mode before reading the file
autocmd BufReadPre,FileReadPre *.gz,*.bz2 set bin
autocmd BufReadPost,FileReadPost *.gz call GZIP_read("gunzip")
autocmd BufReadPost,FileReadPost *.bz2 call GZIP_read("bunzip2")
autocmd BufWritePost,FileWritePost *.gz call GZIP_write("gzip")
autocmd BufWritePost,FileWritePost *.bz2 call GZIP_write("bzip2")
autocmd FileAppendPre *.gz call GZIP_appre("gunzip")
autocmd FileAppendPre *.bz2 call GZIP_appre("bunzip2")
autocmd FileAppendPost *.gz call GZIP_write("gzip")
autocmd FileAppendPost *.bz2 call GZIP_write("bzip2")
" After reading compressed file: Uncompress text in buffer with "cmd"
fun! GZIP_read(cmd)
let ch_save = &ch
set ch=2
execute "'[,']!" . a:cmd
set nobin
let &ch = ch_save
execute ":doautocmd BufReadPost " . expand("%:r")
endfun
" After writing compressed file: Compress written file with "cmd"
fun! GZIP_write(cmd)
if rename(expand("<afile>"), expand("<afile>:r")) == 0
execute "!" . a:cmd . " <afile>:r"
endif
endfun
" Before appending to compressed file: Uncompress file with "cmd"
fun! GZIP_appre(cmd)
execute "!" . a:cmd . " <afile>"
call rename(expand("<afile>:r"), expand("<afile>"))
endfun
augroup END
endif " has("autocmd")
"-----------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment