Skip to content

Instantly share code, notes, and snippets.

@JasonLABS
Last active August 10, 2023 14:00
Show Gist options
  • Save JasonLABS/d31c77cb9432303722f89fcbb2fbbe92 to your computer and use it in GitHub Desktop.
Save JasonLABS/d31c77cb9432303722f89fcbb2fbbe92 to your computer and use it in GitHub Desktop.
""" Setting up .vim folder
""" Structure- .vim->indent->html.vim
""" html.vim - contains one line:-> let b:did_indent = 1
""" ^ removes auto indent from happening
""" ref - https://vim.fandom.com/wiki/How_to_stop_auto_indenting
""" vim-plug - tips
""" https://github.com/junegunn/vim-plug/wiki/tips#automatic-installation
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
""" Installing plugins
""" 1. Plug 'githubuser/plugin-name'
""" 2. :PlugInstall
""" Removing plugins
""" 1. Remove or comment out from the list
""" 2. :PlugClean
call plug#begin('~/.vim/plugged')
Plug 'mhartington/oceanic-next'
Plug 'othree/html5.vim' "for OceanicNext colorscheme
Plug 'othree/yajs.vim' "for OceanicNext colorscheme
Plug 'HerringtonDarkholme/yats.vim/' "for OceanicNext Colorscheme
Plug 'scrooloose/nerdtree' "Installing NerdTree
Plug 'Yggdroot/indentLine' "displaying thin vertical lines at each indentation level for code indented with spaces
Plug 'rust-lang/rust.vim' "Rust plugin for syntax highlighting
call plug#end()
""" Color Scheme Settings for oceanic - START
" Theme
syntax enable
" for vim 8
if (has("termguicolors"))
set termguicolors
endif
colorscheme OceanicNext
""" Color Scheme Settings for oceanic - END
""" https://stackoverflow.com/questions/234564/tab-key-4-spaces-and-auto-indent-after-curly-braces-in-vim
""" Tabs to spaces - 4 spaces - START
""" This is deactivated unless I need it. (currently active)
filetype plugin indent on
""" show existing tab with 4 spaces width
set tabstop=4
""" when indenting with '>', use 4 spaces width
set shiftwidth=4
""" On pressing tab, insert 4 spaces
set expandtab
""" Tabs to spaces - 4 spaces - END
""" html5.vim settings - START
let g:html5_event_handler_attributes_complete = 0
let g:html5_rdfa_attributes_complete = 0
let g:html5_microdata_attributes_complete = 0
let g:html5_aria_attributes_complete = 0
""" html5.vim settings - END
""" yats.vim settings - START
let g:yats_host_keyword = 1
""" yats.vim settings - END
""" VIM hints and options
""" https://aonemd.github.io/blog/handy-keymaps-in-vim
""" Remap leader key to ,
""" let mapleader=","
:let mapleader = ","
""" save current buffer
nnoremap <leader>w :w<cr>
""" Use template to inser text from template
""" https://stackoverflow.com/a/55469715
""" nnoremap <space>p :0read $HOME/.vim/templates/html/p.html<CR>/><CR>
"nnoremap <space>p :r $HOME/.vim/templates/html/p.html<CR>/><CR>
"nnoremap <space>o :r $HOME/.vim/templates/html/o.html<CR>/><CR>
"nnoremap <space>b :0read $HOME/.vim/templates/html/bootstrap.html<CR>/1><CR>
"nnoremap <space>c :r $HOME/.vim/templates/html/container.html<CR>/1><CR>
"nnoremap <space>s :r $HOME/.vim/templates/html/s.html<CR>
"nnoremap <space>m :r $HOME/.vim/templates/html/bootstrapmaintenance.html<CR>
""" basics - this just activates line numbers
"set number
""" Hybrid Numbers
""" https://jeffkreeftmeijer.com/vim-number/
set number relativenumber
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
augroup END
set ruler
""" Spell Checking Highlight Color Settings
"""https://stackoverflow.com/questions/6008921/how-do-i-change-the-highlight-style-in-vim-spellcheck
""" In vim activate by - :set spell
""" deactivate by - :set nospell
hi clear SpellBad
hi SpellBad cterm=underline ctermfg=red
""" Removes the highlight (no hilight) from searches
""" set nohlsearch
""" Inserts datetime stamp on insert mode
""" http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_1)
""" http://vim.wikia.com/wiki/Insert_current_date_or_time
map! <F2> <C-R>=strftime('%Y-%m-%d %H:%M:%S %a %Z')<CR>
map! <F3> <C-R>=strftime('[%Y-%m-%d %a]')<CR>
map! <F4> <C-R>=strftime('[%Y-%m-%d %a %H:%M]')<CR>
""" Maping jj to exit insert mode
inoremap jj <ESC>
""" Case insensitive search set
""" I can use \C to do a case-sensitive search
""" Regular use: You need to use the \c escape sequence. So: /\ccopyright
set ignorecase
""" VIM copying to clipboard
""" https://vi.stackexchange.com/questions/84/how-can-i-copy-text-to-the-system-clipboard-from-vim
""" This needs (Ubuntu 18.04 - sudo apt install vim-gtk)
noremap y "+y
noremap p "+p
""" Change cursor on insert and keep same on replace
""" https://vi.stackexchange.com/a/9133
" 1 -> blinking block
" 2 -> solid block
" 3 -> blinking underscore
" 4 -> solid underscore
" 5 -> blinking vertical bar
" 6 -> solid vertical bar
let &t_SI = "\<esc>[6 q"
let &t_SR = "\<esc>[2 q"
let &t_EI = "\<esc>[2 q"
""" Display tabs (without spaces)
:set listchars=tab:>-,trail:·,extends:>,precedes:<
:set list
""" Set color column at line 80
""" https://vi.stackexchange.com/questions/356/how-can-i-set-up-a-ruler-at-a-specific-column
set colorcolumn=80
""" NerdTree always on
""" https://stackoverflow.com/questions/3788903/how-to-start-vim-with-nerd-tree-opened-automatically
""" 2019-10-21 15:00:38 Mon CDT - I turned it off because I'm not sure I want
""" it on every time
""" autocmd VimEnter * NERDTree
""" HTML tab = 2 spaces
""" https://stackoverflow.com/a/20567731
""" ^ Explanation of html: 2 spaces, C: 8 spaces, Python: 4 spaces
""" https://vi.stackexchange.com/questions/12915/expand-tab-into-2-spaces-when-and-only-when-editing-html
autocmd BufRead,BufNewFile *.htm,*.html,*.sass,*.scss,*.css,*.yml setlocal tabstop=2 shiftwidth=2 softtabstop=2
""" C tab = 8 spaces
autocmd BufRead,BufNewFile *.c setlocal tabstop=8 shiftwidth=8 softtabstop=8
""" Let NERDtree see hidden files
""" Shift+i to toggle setting
""" ref: https://undebugable.wordpress.com/2017/07/02/vim-hide-hidden-files-from-nerdtree/
let NERDTreeShowHidden=1
""" Get rid of autosaves, backup files, and swap files generated by vim
""" ref: https://gist.github.com/bnagy/8914f712f689cc01c267
set nobackup
set noswapfile
set nowritebackup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment