Skip to content

Instantly share code, notes, and snippets.

@mezcel
Last active May 5, 2021 12:02
Show Gist options
  • Select an option

  • Save mezcel/7293290230cda8dc69d1ad0a67ad4250 to your computer and use it in GitHub Desktop.

Select an option

Save mezcel/7293290230cda8dc69d1ad0a67ad4250 to your computer and use it in GitHub Desktop.
vim notes
## win10 line endins
*.bat eol=crlf
*.ps1 eol=crlf
## Linux/Posix line endins
*.sh eol=lf
Makefile eol=lf

Vim Notes

  • Vim usage notes and reminders
  • Config files and macros
  • Reference links
## clone this repo from bash
git clone https://gist.github.com/7293290230cda8dc69d1ad0a67ad4250.git ~/gist.github/$(whoami)/vim-notes.git

.vimrc Color Settiings

list and use builtin color scheeme

:colorscheme [space] [Ctrl-d]

background color

"Normal is background
"ctermbg is background terminal color
highlight Normal ctermbg=Blue

other colors

highlight Comment ctermbg=DarkGray
highlight Constant ctermbg=Blue
highlight Normal ctermbg=Black
highlight NonText ctermbg=Black
highlight Special ctermbg=DarkMagenta
highlight Cursor ctermbg=Green

" this next line is needed to enable your custom colors:
syntax enable

copy andd paste using registers

"" copy to the register "q"
"q yw

"" paste from the register "q"
"q p

Links:

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" %USERPROFILE%\_vimrc
""
"" Vim on ( Command Prompt / Powershell )
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Get default settings.
source $VIMRUNTIME/defaults.vim
if has( "vms" )
set nobackup "do not keep a backup file, use versions instead
endif
if &t_Co > 2 || has( "gui_running" )
"" Switch on highlighting the last used search pattern.
set hlsearch
endif
"" Add optional packages.
"" The matchit plugin makes the % command work better,
"" but it is not backwards compatible.
if has( 'syntax' ) && has( 'eval' )
packadd matchit
endif
syntax on
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" set temp swap files in a custom dir
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" set swapfile wls
"set backupdir=.backup/,~/.backup/,/tmp//
"set directory=.swp/,~/.swp/,/tmp//
"set undodir=.undo/,~/.undo/,/tmp//
"" .vimrc file paths for gitbash
"set backupdir=~/AppData/Roaming/vim/backup/
"set directory=~/AppData/Roaming/vim/swp/
"set undodir=~/AppData/Roaming/vim/undo/
"" _vimrc file paths for cmd
set backupdir=%UserProfile%\backup\
set directory=%UserProfile%\swp\
set undodir=%UserProfile%\undo\
""silent !mkdir %UserProfile%\vim\backup\
""silent !mkdir %UserProfile%\vim\swp\
""silent !mkdir %UserProfile%\vim\undo\
"" prevent automatic backup files
" set nobackup
if v:progname =~? "evim"
finish
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" automatically display line numbers
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set number
set linebreak
set autoindent
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Indent fold presets
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" za toggles fold
"" zM fold all
"" zR unfold all
"" xo open fold
"set foldmethod=indent
"set foldmethod=syntax
"set foldnestmax=10
"set foldlevel=2
set foldmethod=manual
"set nofoldenable
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Tabs
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" use 4 spaces for tabs
set tabstop=4
set shiftwidth=4
set expandtab
set smarttab
"" Unicode Decoration
"" Ctrl+v u2002 for a "blank space"
"" u21D2 ⇒ Rightwards Double Arrow
"" u21E2 ⇢ Rightwards Dashed Arrow
"" u21A6 ↦ Rightwards Arrow From Bar
"" u2192 → Rightwards Arrow
"" u21E5 ⇥ Rightwards Arrow To Bar
"" u21E8 ⇨ Rightwards White Arrow
"" u21F0 ⇰ Rightwards White Arrow From Wall
"" u21FE ⇾ Rightwards Open-Headed Arrow
"" u21F6 ⇶ Three Rightwards Arrows
"" u25B6 ▶ BLACK RIGHT-POINTING TRIANGLE
"" u2506 ┆ Box Drawings Light Triple Dash Vertical
"" u2507 ┇ Box Drawings Heavy Triple Dash Vertical
"" u250A ┊ Box Drawings Light Quadruple Dash Vertical
"" u250B ┋ Box Drawings Heavy Quadruple Dash Vertical
"" u00B7 · Middle Dot
"set listchars=tab:\|\
set listchars=tab:\|.
"set listchars=tab:\┊·
set list
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Long line markers
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set colorcolumn=80,120
highlight ColorColumn guibg=red
"set cursorcolumn
set cursorline
"" Center cursor line by 100 visible lines
set scrolloff=100
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" copy and paste into vim terminal
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set paste
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" split divide char to nothing
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"set fillchars+=vert:\ 
set fillchars+=vert:\|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""" Word processing
"" activate :WP
"" goto misspelled word ]s or [s
"" list spelling options z=
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! WordProcessor()
"" movement changes
map j gj
map k gk
"" formatting text
setlocal formatoptions=1
setlocal noexpandtab
setlocal wrap
setlocal linebreak
"" spelling and thesaurus
setlocal spell spelllang=en_us
"" Download and Use a Pre-defined Thesaurus
"" wget http://www.gutenberg.org/dirs/etext02/mthes10.zip
"set thesaurus+=/home/test/.vim/thesaurus/mthesaur.txt
" complete+=s makes autocompletion search the thesaurus
"set complete+=s
endfunction
com! WP call WordProcessor()
"""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""" My macros EXAMPLES
"""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"let @h="iHello World!\<CR>bye\<Esc>"
"let @f="\<esc>o\<esc>ifor ( int i = 0; i < 10; i++ ) {\<esc>o // do stuff\<esc>o}\<esc>o \<esc>"
"let @i="\<esc>o\<esc>iif ( 1 ) {\<esc>o \<esc>o}\<esc>o \<esc>"
"let @c="\<esc>o\<esc>i/* \<esc>76i*\<esc>o *\<esc>o\<esc>i * \<esc>76i*\<esc>i*/ \<esc>D\<esc>o\<esc>"
"" fold lines between "{" and "}"
let @f="\<esc>f{v%zf"
"""" copy line to register variable "q"
"" useful for copying bash 1-liners to the vim terminal
let @q="\<esc>0\"qy$"
"""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""" Nerdtree (Win10)
""""
"""" Install:
"""" git clone https://github.com/preservim/nerdtree.git %UserProfile%\vimfiles\pack\vendor\start\nerdtree
"""" vim -u NONE -c "helptags ~/vimfiles/pack/vendor/start/nerdtree/doc" -c q
"""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""" Toggle Nerdtree
"" :NERDTreeToggle
"""" Open a NERDTree automatically when vim starts up
"autocmd vimenter * NERDTree
"""" open a NERDTree automatically when vim starts up if no files were specified
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
"""" Close vim if the only window left open is a NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
mkdir %UserProfile%\backup\
mkdir %UserProfile%\swp\
mkdir %UserProfile%\undo\
mkdir %UserProfile%\vimfiles\pack\themes\start
git clone https://github.com/dracula/vim.git %UserProfile%\vimfiles\pack\themes\start\dracula
git clone https://github.com/morhetz/gruvbox.git %UserProfile%\vimfiles\pack\themes\start\gruvbox
git clone https://github.com/arcticicestudio/nord-vim.git %UserProfile%\vimfiles\pack\themes\start\nord
#!/bin/bash
mkdir -p ~/backup/
mkdir -p ~/swp/
mkdir -p ~/undo/
git clone https://github.com/preservim/nerdtree.git ~/.vim/pack/vendor/start/nerdtree
if [ -d ~/.vim/pack/vendor/start/nerdtree ]; then
ttyNestedString "Sourcing NERDTree scripts through Vim ..." "$MODE_BOLD$FG_GREEN"
sleep 4s
sudo vim -u NONE -c "helptags ~/.vim/pack/vendor/start/nerdtree/doc" -c q
sleep 1s
fi
:: vimrc/plugins/colorschemes/ should be in your %UserProfile% directory
mkdir %UserProfile%\backup\
mkdir %UserProfile%\swp\
mkdir %UserProfile%\undo\
mkdir %UserProfile%\vimfiles\
:: git clone https://github.com/preservim/nerdtree.git ~/.vim/pack/vendor/start/nerdtree
git clone https://github.com/preservim/nerdtree.git %UserProfile%\vimfiles\pack\vendor\start\nerdtree
vim -u NONE -c "helptags %UserProfile%\vimfiles\pack\vendor\start\nerdtree\doc" -c q
#!/bin/bash
mkdir -p ~/backup/
mkdir -p ~/swp/
mkdir -p ~/undo/
mkdir -p ~/vimfiles/pack/vendor/start/
git clone https://github.com/preservim/nerdtree.git ~/vimfiles/pack/vendor/start/nerdtree
sudo vim -u NONE -c "helptags ~/vimfiles/pack/vendor/start/nerdtree/doc" -c q
#!/bin/bash
##
## linux-swap.sh
## About: vim swap files
##
## backup
mkdir -p ~/.vim/backup
## swp
mkdir -p ~/.vim/swp
## undo
mkdir -p ~/.vim/undo

Vim notes

Topics


Split

Command Mode Normal Mode About
:split vertical split screen vertically
^Ww toggles cursor between splits
^Wc close a split panel splits
^Wn split screen to a new document
^Wr rotate split window order
## Open multiple file in split mode
vim -o file1 file2
vim -O file1 file2

Tabs

Command Mode Normal Mode About
:tabedit Open a new tab page and edit the file name under the cursor and jump to the line number following the file name.
:tabnext gt cycles to another tab
:tabnew starts a new document in a new tab
:tabclose close tab
## open multiple tab files
vim -p file1 file2 file3

Terminal

Command Mode Normal Mode About
:terminal opens a terminal
^W: enter command mode in a terminal tabed or split within vim
^Wx or ^Wr swap rotate splits
^\ or ^N normal mode

REGEX

Vim tips: The basics of search and replace

  • ^$ match any line without any characters
  • . match single char
  • ^ start of line
  • $ EOL
  • \s White space
  • \S Non-White space
  • \d digit
  • \D Non-digit
  • \u Upper case
  • \U Non-Upper case
  • \l lower case
  • \L Non-lower case
Command Mode Normal Mode About
:%s/patternOriginal/patternNew/g replace all matching chars in doc
:11,15 s/patternOriginal/patternNew/g replace all matching chars in doc in lines 11-50
s/\<term\>/replace/gc search phrase even if EOL

Blocks

Command Mode Normal Mode About
vf{%} select all lines between {}

Misc

Command Mode Normal Mode About
q<a letter to store keystrokes> record keystrokes
@<letter> perform macro stored on a letter
m<a marker letter> line marker
`<marker letter> jump to position marker
ci( change within ()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" ~/.vimrc
""
"" Vim on Debian
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Get default settings.
source $VIMRUNTIME/defaults.vim
if has("vms")
set nobackup " do not keep a backup file, use versions instead
endif
if &t_Co > 2 || has("gui_running")
"" Switch on highlighting the last used search pattern.
set hlsearch
endif
"" Add optional packages.
"" The matchit plugin makes the % command work better,
"" but it is not backwards compatible.
if has( 'syntax' ) && has( 'eval' )
packadd matchit
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" set temp swap files in a custom dir
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" set swapfile
set backupdir=.backup/,~/.backup/,/tmp//
set directory=.swp/,~/.swp/,/tmp//
set undodir=.undo/,~/.undo/,/tmp//
"" prevent automatic backup files
" set nobackup
if v:progname =~? "evim"
finish
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" automatically display line numbers
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set number
set linebreak
set autoindent
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Indent fold presets
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"set foldmethod=indent
"set foldmethod=syntax
"set foldmethod=indent
"set foldnestmax=10
set nofoldenable
"set foldlevel=2
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Tabs
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" use 4 spaces for tabs
set tabstop=4
set shiftwidth=4
set expandtab
set smarttab
"" Unicode Decoration
"" Ctrl+v u2002 for a "blank space"
"" u21D2 ⇒ Rightwards Double Arrow
"" u21E2 ⇢ Rightwards Dashed Arrow
"" u21A6 ↦ Rightwards Arrow From Bar
"" u2192 → Rightwards Arrow
"" u21E5 ⇥ Rightwards Arrow To Bar
"" u21E8 ⇨ Rightwards White Arrow
"" u21F0 ⇰ Rightwards White Arrow From Wall
"" u21FE ⇾ Rightwards Open-Headed Arrow
"" u21F6 ⇶ Three Rightwards Arrows
"" u25B6 ▶ BLACK RIGHT-POINTING TRIANGLE
"" u2506 ┆ Box Drawings Light Triple Dash Vertical
"" u2507 ┇ Box Drawings Heavy Triple Dash Vertical
"" u250A ┊ Box Drawings Light Quadruple Dash Vertical
"" u250B ┋ Box Drawings Heavy Quadruple Dash Vertical
""set listchars=tab:\|\
set listchars=tab:\┊ 
set list
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Long line markers
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set colorcolumn=80,120
highlight ColorColumn guibg=red
"set cursorcolumn
set cursorline
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" copy and paste into vim terminal
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set paste
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" split divide char to nothing
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set fillchars+=vert:\
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""" Word processing
"" activate :WP
"" goto misspelled word ]s or [s
"" list spelling options z=
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! WordProcessor()
" movement changes
map j gj
map k gk
" formatting text
setlocal formatoptions=1
setlocal noexpandtab
setlocal wrap
setlocal linebreak
" spelling and thesaurus
setlocal spell spelllang=en_us
"" Download and Use a Pre-defined Thesaurus
"" wget http://www.gutenberg.org/dirs/etext02/mthes10.zip
"set thesaurus+=/home/test/.vim/thesaurus/mthesaur.txt
" complete+=s makes autocompletion search the thesaurus
"set complete+=s
endfunction
com! WP call WordProcessor()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" My macros
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let @h="iHello World!\<CR>bye\<Esc>"
let @f="\<esc>o\<esc>ifor ( int i = 0; i < 10; i++ ) {\<esc>o // do stuff\<esc>o}\<esc>o \<esc>"
let @i="\<esc>o\<esc>iif ( 1 ) {\<esc>o \<esc>o}\<esc>o \<esc>"
let @c="\<esc>o\<esc>i/* \<esc>76i*\<esc>o *\<esc>o\<esc>i * \<esc>76i*\<esc>i*/ \<esc>D\<esc>o\<esc>"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Decorative Status Line
"" help: statusline
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"set ruler
set laststatus=2
set statusline=%f%m%r%h%w\ [%Y]\ [0x%02.2B]%<\ %F\ %=(col:%4v,\ row:%4l/%4L)\ %3p%%\
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" ~/.vimrc
""
"" Vim on Git Bash ( Archlinux )
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" automatically display line numbers
set number
set linebreak
set autoindent
"" set temp swap files in a custom dir
" set swapfile
set backupdir=.backup/,~/.backup/,/tmp//
set directory=.swp/,~/.swp/,/tmp//
set undodir=.undo/,~/.undo/,/tmp//
"" Indent fold presets
"set foldmethod=indent
"set foldmethod=syntax
"set foldmethod=indent
"set foldnestmax=10
set nofoldenable
"set foldlevel=2
set tabstop=4 shiftwidth=4
set expandtab smarttab
"" copy and paste into vim terminal
set paste
"" prevent automatic backup files
" set nobackup
if v:progname =~? "evim"
finish
endif
"" Get the defaults that most users want.
source $VIMRUNTIME/defaults.vim
if has("vms")
set nobackup " do not keep a backup file, use versions instead
endif
if &t_Co > 2 || has("gui_running")
"" Switch on highlighting the last used search pattern.
set hlsearch
endif
"" Add optional packages.
"" The matchit plugin makes the % command work better, but it is not backwards compatible.
if has('syntax') && has('eval')
packadd matchit
endif
""" Word processing
"" activate :WP
"" goto misspelled word ]s or [s
"" list spelling options z=
func! WordProcessor()
" movement changes
map j gj
map k gk
" formatting text
setlocal formatoptions=1
setlocal noexpandtab
setlocal wrap
setlocal linebreak
" spelling and thesaurus
setlocal spell spelllang=en_us
"" Download and Use a Pre-defined Thesaurus
"" wget http://www.gutenberg.org/dirs/etext02/mthes10.zip
"set thesaurus+=/home/test/.vim/thesaurus/mthesaur.txt
" complete+=s makes autocompletion search the thesaurus
"set complete+=s
endfu
com! WP call WordProcessor()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" %USERPROFILE%\_vimrc
""
"" Vim on ( Command Prompt / Powershell )
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Get default settings.
source $VIMRUNTIME/defaults.vim
if has( "vms" )
set nobackup "do not keep a backup file, use versions instead
endif
if &t_Co > 2 || has( "gui_running" )
"" Switch on highlighting the last used search pattern.
set hlsearch
endif
"" Add optional packages.
"" The matchit plugin makes the % command work better,
"" but it is not backwards compatible.
if has( 'syntax' ) && has( 'eval' )
packadd matchit
endif
syntax on
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" set temp swap files in a custom dir
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" set swapfile wls
"set backupdir=.backup/,~/.backup/,/tmp//
"set directory=.swp/,~/.swp/,/tmp//
"set undodir=.undo/,~/.undo/,/tmp//
"" .vimrc file paths for gitbash
"set backupdir=~/AppData/Roaming/vim/backup/
"set directory=~/AppData/Roaming/vim/swp/
"set undodir=~/AppData/Roaming/vim/undo/
"" _vimrc file paths for cmd
set backupdir=%APPDATA%\vim\backup\
set directory=%APPDATA%\vim\swp\
set undodir=%APPDATA%\vim\undo\
"" prevent automatic backup files
" set nobackup
if v:progname =~? "evim"
finish
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" automatically display line numbers
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set number
set linebreak
set autoindent
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Indent fold presets
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" za toggles fold
"" zM fold all
"" zR unfold all
"" xo open fold
set foldmethod=indent
set foldmethod=syntax
"set foldnestmax=10
"set foldlevel=2
"set nofoldenable
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Tabs
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" use 4 spaces for tabs
set tabstop=4
set shiftwidth=4
set expandtab
set smarttab
"" Unicode Decoration
"" Ctrl+v u2002 for a "blank space"
"" u21D2 ⇒ Rightwards Double Arrow
"" u21E2 ⇢ Rightwards Dashed Arrow
"" u21A6 ↦ Rightwards Arrow From Bar
"" u2192 → Rightwards Arrow
"" u21E5 ⇥ Rightwards Arrow To Bar
"" u21E8 ⇨ Rightwards White Arrow
"" u21F0 ⇰ Rightwards White Arrow From Wall
"" u21FE ⇾ Rightwards Open-Headed Arrow
"" u21F6 ⇶ Three Rightwards Arrows
"" u25B6 ▶ BLACK RIGHT-POINTING TRIANGLE
"" u2506 ┆ Box Drawings Light Triple Dash Vertical
"" u2507 ┇ Box Drawings Heavy Triple Dash Vertical
"" u250A ┊ Box Drawings Light Quadruple Dash Vertical
"" u250B ┋ Box Drawings Heavy Quadruple Dash Vertical
"" u00B7 · Middle Dot
"set listchars=tab:\|\
set listchars=tab:\|.
"set listchars=tab:\┊·
set list
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Long line markers
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set colorcolumn=80,120
highlight ColorColumn guibg=red
"set cursorcolumn
set cursorline
"" Center cursor line by 100 visible lines
set scrolloff=100
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" copy and paste into vim terminal
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set paste
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" split divide char to nothing
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"set fillchars+=vert:\ 
set fillchars+=vert:\|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""" Word processing
"" activate :WP
"" goto misspelled word ]s or [s
"" list spelling options z=
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! WordProcessor()
"" movement changes
map j gj
map k gk
"" formatting text
setlocal formatoptions=1
setlocal noexpandtab
setlocal wrap
setlocal linebreak
"" spelling and thesaurus
setlocal spell spelllang=en_us
"" Download and Use a Pre-defined Thesaurus
"" wget http://www.gutenberg.org/dirs/etext02/mthes10.zip
"set thesaurus+=/home/test/.vim/thesaurus/mthesaur.txt
" complete+=s makes autocompletion search the thesaurus
"set complete+=s
endfunction
com! WP call WordProcessor()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" My macros
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let @h="iHello World!\<CR>bye\<Esc>"
let @f="\<esc>o\<esc>ifor ( int i = 0; i < 10; i++ ) {\<esc>o // do stuff\<esc>o}\<esc>o \<esc>"
let @i="\<esc>o\<esc>iif ( 1 ) {\<esc>o \<esc>o}\<esc>o \<esc>"
let @c="\<esc>o\<esc>i/* \<esc>76i*\<esc>o *\<esc>o\<esc>i * \<esc>76i*\<esc>i*/ \<esc>D\<esc>o\<esc>"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Decorative Status Line
"" help: statusline
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"set ruler
set laststatus=2
set statusline=%f%m%r%h%w\ [%Y]\ [0x%02.2B]%<\ %F\ %=(col:%4v,\ row:%4l/%4L)\ %3p%%\
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" ~/.vimrc
""
"" Vim on Debian ( Linux / WLS )
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Get default settings.
source $VIMRUNTIME/defaults.vim
if has( "vms" )
set nobackup "do not keep a backup file, use versions instead
endif
if &t_Co > 2 || has( "gui_running" )
"" Switch on highlighting the last used search pattern.
set hlsearch
endif
"" Add optional packages.
"" The matchit plugin makes the % command work better,
"" but it is not backwards compatible.
if has( 'syntax' ) && has( 'eval' )
packadd matchit
endif
syntax on
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" set temp swap files in a custom dir
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" set swapfile
set backupdir=.backup/,~/.backup/,/tmp//
set directory=.swp/,~/.swp/,/tmp//
set undodir=.undo/,~/.undo/,/tmp//
"" prevent automatic backup files
" set nobackup
if v:progname =~? "evim"
finish
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" automatically display line numbers
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set number
set linebreak
set autoindent
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Indent fold presets
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" za toggles fold
"" zM fold all
"" zR unfold all
"" xo open fold
set foldmethod=indent
set foldmethod=syntax
"set foldnestmax=10
"set foldlevel=2
"set nofoldenable
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Tabs
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" use 4 spaces for tabs
set tabstop=4
set shiftwidth=4
set expandtab
set smarttab
"" Unicode Decoration
"" Ctrl+v u2002 for a "blank space"
"" u21D2 ⇒ Rightwards Double Arrow
"" u21E2 ⇢ Rightwards Dashed Arrow
"" u21A6 ↦ Rightwards Arrow From Bar
"" u2192 → Rightwards Arrow
"" u21E5 ⇥ Rightwards Arrow To Bar
"" u21E8 ⇨ Rightwards White Arrow
"" u21F0 ⇰ Rightwards White Arrow From Wall
"" u21FE ⇾ Rightwards Open-Headed Arrow
"" u21F6 ⇶ Three Rightwards Arrows
"" u25B6 ▶ BLACK RIGHT-POINTING TRIANGLE
"" u2506 ┆ Box Drawings Light Triple Dash Vertical
"" u2507 ┇ Box Drawings Heavy Triple Dash Vertical
"" u250A ┊ Box Drawings Light Quadruple Dash Vertical
"" u250B ┋ Box Drawings Heavy Quadruple Dash Vertical
"" u00B7 · Middle Dot
""set listchars=tab:\|\
"set listchars=tab:\┊ 
set listchars=tab:\┊·
set list
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Long line markers
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set colorcolumn=80,120
highlight ColorColumn guibg=red
"set cursorcolumn
set cursorline
"" Center cursor line by 100 visible lines
set scrolloff=100
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" copy and paste into vim terminal
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set paste
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" split divide char to nothing
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set fillchars+=vert:\ 
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""" Word processing
"" activate :WP
"" goto misspelled word ]s or [s
"" list spelling options z=
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! WordProcessor()
"" movement changes
map j gj
map k gk
"" formatting text
setlocal formatoptions=1
setlocal noexpandtab
setlocal wrap
setlocal linebreak
"" spelling and thesaurus
setlocal spell spelllang=en_us
"" Download and Use a Pre-defined Thesaurus
"" wget http://www.gutenberg.org/dirs/etext02/mthes10.zip
"set thesaurus+=/home/test/.vim/thesaurus/mthesaur.txt
" complete+=s makes autocompletion search the thesaurus
"set complete+=s
endfunction
com! WP call WordProcessor()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" My macros
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let @h="iHello World!\<CR>bye\<Esc>"
let @f="\<esc>o\<esc>ifor ( int i = 0; i < 10; i++ ) {\<esc>o // do stuff\<esc>o}\<esc>o \<esc>"
let @i="\<esc>o\<esc>iif ( 1 ) {\<esc>o \<esc>o}\<esc>o \<esc>"
let @c="\<esc>o\<esc>i/* \<esc>76i*\<esc>o *\<esc>o\<esc>i * \<esc>76i*\<esc>i*/ \<esc>D\<esc>o\<esc>"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Decorative Status Line
"" help: statusline
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""set ruler in statusline
set laststatus=2
"" Show git branch in status bar
function! GitBranch()
return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'")
endfunction
function! StatuslineGit()
let l:branchname = GitBranch()
return strlen(l:branchname) > 0?' '.l:branchname.' ':''
endfunction
"" Status line string
"set statusline=%f%m%r%h%w\ [%Y]\ [0x%02.2B]%<\ %F\ %=(col:%4v,\ row:%4l/%4L)\ %3p%%\ 
set statusline=[%{StatuslineGit()}]\ %f%m%r%h%w\ [%Y]\ [0x%02.2B]%<\ %F\ %=(col:%4v,\ row:%4l/%4L)\ %3p%%\ 
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" ~/.vimrc
""
"" Vim on ( Git Bash - Win10 )
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Get default settings.
source $VIMRUNTIME/defaults.vim
if has( "vms" )
set nobackup "do not keep a backup file, use versions instead
endif
if &t_Co > 2 || has( "gui_running" )
"" Switch on highlighting the last used search pattern.
set hlsearch
endif
"" Add optional packages.
"" The matchit plugin makes the % command work better,
"" but it is not backwards compatible.
if has( 'syntax' ) && has( 'eval' )
packadd matchit
endif
syntax on
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" set temp swap files in a custom dir
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" set swapfile wls
"set backupdir=.backup/,~/.backup/,/tmp//
"set directory=.swp/,~/.swp/,/tmp//
"set undodir=.undo/,~/.undo/,/tmp//
"" .vimrc file paths for gitbash
set backupdir=~/AppData/Roaming/vim/backup/
set directory=~/AppData/Roaming/vim/swp/
set undodir=~/AppData/Roaming/vim/undo/
"" .vimrc file paths for cmd
"set backupdir=%APPDATA%\vim\backup\
"set directory=%APPDATA%\vim\swp\
"set undodir=%APPDATA%\vim\undo\
"" prevent automatic backup files
" set nobackup
if v:progname =~? "evim"
finish
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" automatically display line numbers
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set number
set linebreak
set autoindent
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Indent fold presets
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" za toggles fold
"" zM fold all
"" zR unfold all
"" xo open fold
set foldmethod=indent
set foldmethod=syntax
"set foldnestmax=10
"set foldlevel=2
"set nofoldenable
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Tabs
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" use 4 spaces for tabs
set tabstop=4
set shiftwidth=4
set expandtab
set smarttab
"" Unicode Decoration
"" Ctrl+v u2002 for a "blank space"
"" u21D2 ⇒ Rightwards Double Arrow
"" u21E2 ⇢ Rightwards Dashed Arrow
"" u21A6 ↦ Rightwards Arrow From Bar
"" u2192 → Rightwards Arrow
"" u21E5 ⇥ Rightwards Arrow To Bar
"" u21E8 ⇨ Rightwards White Arrow
"" u21F0 ⇰ Rightwards White Arrow From Wall
"" u21FE ⇾ Rightwards Open-Headed Arrow
"" u21F6 ⇶ Three Rightwards Arrows
"" u25B6 ▶ BLACK RIGHT-POINTING TRIANGLE
"" u2506 ┆ Box Drawings Light Triple Dash Vertical
"" u2507 ┇ Box Drawings Heavy Triple Dash Vertical
"" u250A ┊ Box Drawings Light Quadruple Dash Vertical
"" u250B ┋ Box Drawings Heavy Quadruple Dash Vertical
"" u00B7 · Middle Dot
""set listchars=tab:\|\
"set listchars=tab:\┊ 
set listchars=tab:\┊·
set list
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Long line markers
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set colorcolumn=80,120
highlight ColorColumn guibg=red
"set cursorcolumn
set cursorline
"""" Center cursor line by n visible lines
"""" 15 from the top/bottom
set scrolloff=15
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" copy and paste into vim terminal
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set paste
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" split window divider
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" set to white space
set fillchars+=vert:\ 
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""" Word processing
"" activate :WP
"" goto misspelled word ]s or [s
"" list spelling options z=
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! WordProcessor()
"" movement changes
map j gj
map k gk
"" formatting text
setlocal formatoptions=1
setlocal noexpandtab
setlocal wrap
setlocal linebreak
"" spelling and thesaurus
setlocal spell spelllang=en_us
"" Download and Use a Pre-defined Thesaurus
"" wget http://www.gutenberg.org/dirs/etext02/mthes10.zip
"set thesaurus+=/home/test/.vim/thesaurus/mthesaur.txt
" complete+=s makes autocompletion search the thesaurus
"set complete+=s
endfunction
com! WP call WordProcessor()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" My macros
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" C Files
function MyMacroC()
"""" For Loop template
let @f="\<esc>o\<esc>ifor ( int i = 0; i < 10; i++ ) {\<esc>o // do stuff\<esc>o}\<esc>o \<esc>"
"""" If statement template
let @i="\<esc>o\<esc>iif ( 1 ) {\<esc>o \<esc>o}\<esc>o \<esc>"
"""" Enlosed comment block
let @c="\<esc>o\<esc>i/* \<esc>76i*\<esc>o *\<esc>o\<esc>i * \<esc>76i*\<esc>i*/ \<esc>D\<esc>o\<esc>"
endfunction
com! MC call MyMacroC()
"" Bash Files
function MyMacroBash()
"""" For Loop template
let @f="\<esc>ofor i in 1 .. N\<esc>odo\<esc>o ## do_stuff\<esc>odone\<esc>o\<esc>\<esc>"
"""" If statement template
let @i="\<esc>oif [ 1 ]; then\<esc>o ## do_stuff\<esc>ofi\<esc>o\<esc>\<esc>0kkkf1"
"""" Enlosed comment block
let @c="\<esc>o################\<esc>o## \<esc>o################\<esc>o\<esc>k\<esc>0k\$a"
endfunction
com! MB call MyMacroBash()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Decorative Status Line
"" help: statusline
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"set ruler
set laststatus=2
set statusline=%f%m%r%h%w\ [%Y]\ [0x%02.2B]%<\ %F\ %=(col:%4v,\ row:%4l/%4L)\ %3p%%\ 
::
:: win10-swap.bat
:: About: vim swap files
::
:: backup
mkdir %APPDATA%\vim\backup\
:: swp
mkdir %APPDATA%\vim\swp\
:: undo
mkdir %APPDATA%\vim\undo\
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment