book
  • README
  • cheatsheet
    • bash
      • builtin
      • syntactic sugar
      • cmd
      • havefun
    • text-processing
      • awk
      • sed
      • html
      • json
      • regex
      • unicode
    • osx
    • curl
    • tricky
    • widget
    • proxy
    • colors
    • math
    • media
    • ssl
      • keystore
      • verification
      • server
      • client
      • tricky
    • windows
      • powershell
      • choco
      • wsl
      • wt
      • shortcut
      • clsid
      • env
      • shell:folder
  • vim
    • nvim
    • install
    • color
    • plugins
      • usage
      • other plugins
      • deprecated
    • tricky
    • viml
    • windows
    • troubleshooting
  • devops
    • admin tools
    • ssh
    • git
      • config
      • alias
      • submodule
      • eol
      • example
      • gerrit
        • gerrit API
      • github
      • troubleshooting
      • tricky
      • statistics
    • pre-commit
    • release-tools
    • tmux
      • cheatsheet
    • ansible
    • vault
    • artifactory
      • api
      • cli
      • aql
      • nginx cert
    • klocwork
      • kwadmin
      • kwserver
      • api
      • q&a
    • elk
    • mongodb
    • android
    • mobile
  • jenkins
    • config
      • windows
    • appearance
    • troubleshooting
    • jenkinsfile
      • utility
      • parallel
      • build
      • envvar
      • properties
      • trigger
      • node
    • script
      • job
      • build
      • stage
      • agent
      • security & authorization
      • exception
      • monitor
      • tricky
    • api
      • blueocean
    • cli
    • plugins
      • kubernetes
      • docker
      • shared-libs
      • lockable-resource
      • ansicolor
      • badge
      • groovy-postbuild
      • simple-theme
      • customizable-header
      • artifactory
      • jira-steps
      • job-dsl
      • build-timeline
      • crumbIssuer
      • coverage
      • uno-choice
      • tricky
  • virtualization
    • kubernetes
      • init
        • kubespray
        • kubeadm
          • environment
          • crio v1.30.4
          • docker v1.15.3
          • HA
        • addons
        • etcd
      • kubectl
        • pod
        • deploy
        • replicasets
        • namespace
        • secrets
      • node
      • certificates
      • events
      • kubeconfig
      • kubelet
      • troubleshooting
      • cheatsheet
      • auth
      • api
      • tools
        • monitor
        • helm
        • network
        • minikube
    • docker
      • run & exec
      • voume
      • remove
      • show info
      • dockerfile
      • dockerd
      • tricky
      • troubleshooting
      • windows
    • crio
    • podman
  • ai
    • prompt
  • osx
    • apps
      • init
      • brew
    • defaults
    • system
    • network
    • script
    • tricky
  • linux
    • devenv
    • util
      • time & date
      • output formatting
      • params
      • tricky
    • nutshell
    • disk
    • network
    • troubleshooting
    • system
      • apt/yum/snap
      • authorization
      • apps
      • x11
    • ubuntu
      • systemctl
      • x
    • rpi
  • programming
    • groovy
    • python
      • config
      • basic
      • list
      • pip
      • q&a
    • others
    • archive
      • angular
      • maven
      • mysql
        • installation
        • logs
      • ruby
        • rubyInstallationQ&A
  • tools
    • fonts
    • html & css
    • Jira & Confluence
    • node & npm
      • gitbook
      • hexo
      • github.page
      • code themes
    • app
      • microsoft office
      • vscode
      • virtualbox
      • iterm2
      • browser
      • skype
      • teamviewer
      • others
  • quotes
  • english
Powered by GitBook
On this page
  • mode
  • shortcuts
  • commands
  • config
  • run vim commands in terminal
  • vim regex
  • vim pattern
  • characters
  • micro
  • others

Was this helpful?

  1. vim

tricky

PreviousdeprecatedNextviml

Last updated 9 days ago

Was this helpful?

[!TIP|label:references:]

mode

diff mode

[!NOTE|label:references:]

:echo &diff
1
  • example

    autocmd BufEnter * if &diff | let g:blamer_enabled=0 | endif            " ╮ disable git blame in diff mode
    autocmd BufEnter * if ! empty(&key) | let g:blamer_enabled=0 | endif    " ╯ and encrypt mode
  • " setup cursor shape to block in diff mode
    function! CursorShapeInDiffMode()
      if &diff
        if $TERM_PROGRAM =~ "iTerm"
          let &t_SI = "\<Esc>]50;CursorShape=1\x7"
          let &t_SR = "\<Esc>]50;CursorShape=2\x7"
          let &t_EI = "\<Esc>]50;CursorShape=2\x7"
        else
          let &t_SI = "\e[1 q"
          let &t_SR = "\e[2 q"
          let &t_EI = "\e[2 q"
        endif
      endif
    endfunction
    autocmd BufRead,BufEnter,BufNewFile * :call CursorShapeInDiffMode()
  • autocmd WinEnter * if &diff | set nocursorline | endif
    
    " or
    au OptionSet diff let &cul=!v:option_new
    
    " or
    augroup CursorLine
      au!
      au FilterWritePost * if &diff | let &cul=0 |endif
      au BufEnter * if !&diff | let &cul=1 |endif
    augroup end

terminal mode

[!NOTE|label:references:]

    • <empty> : normal buffer

    • acwrite : buffer will always be written with BufWriteCmds

    • help : help buffer (do not set this manually)

    • nofile : buffer is not related to a file, will not be written

    • nowrite : buffer will not be written

    • quickfix : list of errors :cwindow or locations :lwindow

    • terminal : terminal-emulator buffer

    • prompt : buffer where only the last line can be edited, meant to be used by a plugin, see |prompt-buffer|

:echo &buftype
terminal
  • autocmd

    autocmd! TermOpen,TermEnter * :IndentLinesDisable
    autocmd! TermOpen           * setlocal nonumber norelativenumber modifiable nospell
    
    " others
    autocmd! BufEnter * if &buftype ==# 'terminal' | setlocal ma | endif
    autocmd! TermOpen,BufEnter term://* :IndentLinesDisable
    autocmd TermClose * echom 'Terminal exited with status '..v:event.status
    • more

      [!NOTE|label:more:]

      " go back to insert mode when entering the terminal window
      autocmd BufEnter * if &buftype == 'terminal' | :startinsert | endif
      
      function! NeovimTermOpen()
        :split
        :terminal
        :startinsert
      endfunction
      
      cabbrev ter call NeovimTermOpen()
    • autocmd BufWinEnter,WinEnter term://* startinsert
      autocmd BufLeave term://* stopinsert
      
      # or https://vi.stackexchange.com/q/25577/7389
      autocmd TermOpen * startinsert
      au BufEnter * if &buftype == 'terminal' | :startinsert | endif
      
      # or https://vi.stackexchange.com/a/25579/7389
      autocmd TerminalOpen * nnoremap <buffer> <c-p> :bdelete!<CR>
  • tnoremap <Esc> <C-\><C-n>
    tnoremap <expr> <C-R> '<C-\><C-N>"'.nr2char(getchar()).'pi'
  • usage:

    • open top command line in vsplit

      :vsplit term://top
      " or
      :vnew | term top
    • :split | resize 10 | terminal
    • autocmd VimEnter * ++nested split term://bash

shortcuts

combine multiple lines with or without space

  • with space: J

shortcut
comments

gcw

capitalize word (from cursor position to end of word)

gcW

capitalize WORD (from cursor position to end of WORD)

gciw

capitalize inner word (from start to end)

gciW

capitalize inner WORD (from start to end)

gcis

capitalize inner sentence

gc$

capitalize until end of line (from cursor postition)

gcgc

capitalize whole line (from start to end)

gcc

capitalize whole line

{Visual}gc

capitalize highlighted text

" vimrc
if ( &tildeop )
  nmap gcw  guw~l
  nmap gcW  guW~l
  nmap gciw guiw~l
  nmap gciW guiW~l
  nmap gcis guis~l
  nmap gc$  gu$~l
  nmap gcgc guu~l
  nmap gcc  guu~l
  vmap gc   gu~l
else
  nmap gcw  guw~h
  nmap gcW  guW~h
  nmap gciw guiw~h
  nmap gciW guiW~h
  nmap gcis guis~h
  nmap gc$  gu$~h
  nmap gcgc guu~h
  nmap gcc  guu~h
  vmap gc   gu~h
endif

[!NOTE|label:references:]

  • lowercase

    gu
    
    " example
    Hello -> hello
  • uppercase

    gU
    
    " example
    Hello -> HELLO
  • reverse

    g~
    
    " example
    Hello -> hELLO
  • more

    • g~3w : toggle case of the next three words

    • g~$ : toggle case to the end of line

    • g~iw : toggle case of the current word (inner word – cursor anywhere in word)

    • g~~ == g~g~ : toggle case of the current line (same as V~ - cursor anywhere in the line)

    • gUU == gUgU : to uppercase of the current line (same as V~ - cursor anywhere in the line)

    • guu == gugu : to lowercase of the current line (same as V~ - cursor anywhere in the line)

counter

[!NOTE|label:references]

nnoremap <leader>cr  0yt=A<C-r>=<C-r>"<CR><Esc>

insert vim expression

  • i/I/a/A/o/O to insert mode

  • ctrl + r + = to insert expression

  • ctrl + r> + " ( ⌘ + v ) to insert the contents of the default register

  • enter

" mapping
nnoremap <leader>ev  A<C-R>=printf(" = %s", eval(getline('.')))<CR><Esc>
nnoremap <leader>Iev I<C-R>=printf("%s", eval(getline('.')))<CR><Esc>
" -- or --
nnoremap <leader>ev  :s/$/\=printf(" = %s", eval(getline('.')))/<CR><Esc>
xnoremap <leader>ev  :s/$/\=printf(" = %s", eval(getline('.')))/<CR><Esc>

" execute
:'<,'> normal ,ev
:'<,'> normal ,Iev

batch insert vim expression

:g/^echo strftime/execute "normal! A # \=" . substitute(getline('.'), '^echo\s\+', '', '')

" or
:g/^echo strftime/let @e = substitute(getline('.'), '^echo\s\+', '', '') | execute 'normal! A  # ' . eval(@e)

[!NOTE|label:references:]

"_dd
  • or ~/.vimrc

    nnoremap rdd  "_dd
    nnoremap rdw  "_dw
cnoremap <C-k> <C-\>e(strpart(getcmdline(), 0, getcmdpos() - 1))<CR>

commands

[!NOTE|label:references:]

" in cursor position"
:.! <command>

" read!
:r! <command>

" in new buffer"
:new | 0read ! <command>

[!NOTE|label:reference:]

CMD

ignorecase

smartcase

MATCHES

foo

off

-

foo

foo

on

-

foo Foo FOO

foo

on

on

foo Foo FOO

Foo

on

on

Foo

Foo

on

-

foo Foo FOO

\cfoo

-

-

foo Foo FOO

foo\C

-

-

foo

:set ignorecase
:set smartcase
/example      " Case insensitive
/Example      " Case sensitive
/example\C    " Case sensitive
/Example\c    " Case insensitive

search with \V

pattern
result

/a.k.a<CR>

backward a.k.a

/a\.k\.a<CR>

backward a.k.a

/Va.k.a<CR>

backward a.k.a

search in visual mode

[!NOTE]

  • v go to visual mode

  • /KEYWORDS search next KEYWORDS | ?KEYWORDS search previous KEYWORDS

  • enter

[!NOTE|label:references:]

  • sort

    :{range}sort
    
    " or
    :sort n
    
    " reverse sort
    :sort nr
  • sort and unique

    :{range}sort u
:echo getcompletion('', 'filetype')
  • or

    :echo getcompletion('c', 'filetype')
  • function! GetFiletypes()
      " Get a list of all the runtime directories by taking the value of that
      " option and splitting it using a comma as the separator.
      let rtps = split(&runtimepath, ",")
      " This will be the list of filetypes that the function returns
      let filetypes = []
    
      " Loop through each individual item in the list of runtime paths
      for rtp in rtps
        let syntax_dir = rtp . "/syntax"
        " Check to see if there is a syntax directory in this runtimepath.
        if (isdirectory(syntax_dir))
          " Loop through each vimscript file in the syntax directory
          for syntax_file in split(glob(syntax_dir . "/*.vim"), "\n")
            " Add this file to the filetypes list with its everything
            " except its name removed.
            call add(filetypes, fnamemodify(syntax_file, ":t:r"))
          endfor
        endif
      endfor
    
      " This removes any duplicates and returns the resulting list.
      " NOTE: This might not be the best way to do this, suggestions are welcome.
      return uniq(sort(filetypes))
    endfunction
  • reference:

- [Vim documentation: pattern](http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5Cr) : - `\n` matches an end of line (newline) - `\r` matches a carriage return (more precisely it’s treated as the input `CR`))

redirect cmd

[!NOTE|label:references:]

  • redir to file

    :redir > ~/Desktop/debug.txt
    :silent highlight
    :redir END
    • :write | redir >> % | silent registers | redir END | edit
  • to new window

    :redir @a | silent digraph | redir END | new +setl\ buftype=nofile\ bufhidden=wipe | put! a
  • [!NOTE|label:references:]

    function! TabMessage( cmd )
      redir => message
      silent execute a:cmd
      redir END
      if empty( message )
        echoerr "no output"
      else
        tabnew               " use "new" instead of "tabnew" below if you prefer split windows instead of tabs
        setlocal buftype=nofile bufhidden=wipe noswapfile nobuflisted nomodified
        silent put=message
      endif
    endfunction
    command! -nargs=+ -complete=command TabMessage call TabMessage(<q-args>)
    
    " usage:
    :TabMessage highlight

insert hex code

METHOD
PROS
CONS

statusline %B

native support

only shows current cursor position

char2nr()

batch processing capability

requires manual handling of encoding ranges

:ascii

displays complete encoding info

requires parsing multi-line output

:%s/^./\=submatch(0).printf(' : %04X', char2nr(submatch(0)))/

" -- result --
"  : F27D
" 󱆃 : F1183
"  : E702
"  : E62B
" using 000xxxxx instead of xxxxx
"                                                                  X: uppercase x: lowercase              X: uppercase x: lowercase
"                                                                              v                                      v
:g/^./s/^\(.\)/\=submatch(1).' : '.(char2nr(submatch(1)) > 0xFFFF ? printf('%08X', char2nr(submatch(1))) : printf('%04X', char2nr(submatch(1))))/
" or using `:s`
:%s/^./\=submatch(0).' : '.(char2nr(submatch(0)) > 0xFFFF ? printf('%08X', char2nr(submatch(0))) : printf('%04X', char2nr(submatch(0))))/

" -- result --
"  : F27D
" 󱆃 : 000F1183
"  : E702
"  : E62B
" or simulator `%B` in statusline
"                             add 0x
"                               v
:%s/^./\=submatch(0).printf(' : 0x%04X', char2nr(submatch(0)))/

" -- result --
"  : 0xF27D
" 󱆃 : 0xF1183
"  : 0xE702
"  : 0xE62B
" insert result of `:ascii`
:%s/.*/\=printf('%s : <%s>  %d,  Hex %x,  Octal %o', submatch(0), submatch(0), char2nr(submatch(0)), char2nr(submatch(0)), char2nr(submatch(0)))/

" -- result --
"  : <>  62077,  Hex f27d,  Octal 171175
" 󱆃 : <󱆃>  987523,  Hex f1183,  Octal 3610603
"  : <>  59138,  Hex e702,  Octal 163402
"  : <>  58923,  Hex e62b,  Octal 163053

using :g /./ :ascii

:g /./ :ascii

" redirect via TabMessage
:TabMessage g /./ :ascii

with function

[!NOTE|label:references:] performance:

SOLUTION
SPEED
PROS
CONS

:ascii

~1.2s

exactly matches the official format

slow

char2nr()

~0.03s

fast

requires custom format

hybrid

~0.5s

balancing speed and format

requires custom format

" simple version"
function! GetAsciiInfo(char) abort
  let code = char2nr(a:char)
  let hex = printf('%X', code)
  let octal= printf('%o', code)
  return printf("'%s' %d 0x%s %o", a:char, code, hex, octal)
endfunction

" usage
:%s/^\(.\)/\=submatch(1) . ' ' . GetAsciiInfo(submatch(1))/g
" support unicode
function! AppendFullCode() range
  for lnum in range(a:firstline, a:lastline)
    let char = getline(lnum)[0]
    let code = char2nr(char)
    let hex = code > 0xffff ? printf("Hex %06x", code) : printf("Hex %04x", code)
    let oct = printf("Octal %o", code)
    call setline( lnum, printf("%s: %d, %s, %s", char, code, hex, oct) )
  endfor
endfunction

" usage
:%call AppendFullCode()
" full version
function! AppendFullAscii() range
  for lnum in range(a:firstline, a:lastline)
    let char = getline(lnum)[0]
    let code = char2nr(char)

    " get code
    let dec = code
    let hex = code > 0xffff ? printf("%08x", code) : printf("%04x", code)
    let oct = printf("%o", code)

    " UTF-8 coding
    let utf8_bytes = []
    let n = code
    while n > 0
      call insert(utf8_bytes, n % 0x100)
      let n = n / 0x100
    endwhile

    " get final string
    let result = printf("%s : DEC %d | HEX %s | OCT %o | UTF-8 %s",
          \ char, dec, hex, oct, join(map(utf8_bytes, 'printf("%02x", v:val)'), ''))
    call setline(lnum, result)
  endfor
endfunction

" usage
:%call AppendAscii()
" using `:ascii` command and redirect
function! AppendAscii() range
  let save = @a
  for lnum in range(a:firstline, a:lastline)
    let char = getline(lnum)[0]

    " go to first column
    execute lnum . 'normal! 0'

    " capture ascii result
    redir @a
    silent! ascii
    redir END

    " format output
    let output = substitute(@a, '\n', '', 'g')
    " remove <x>
    let output = substitute(output, '^<.*>\s*', '', '')
    let output = substitute(output, ',\s*Hex\s*', ', Hex ', '')
    let output = substitute(output, ',\s*Octal\s*', ', Octal ', '')

    " join string
    call setline(lnum, printf("%s: %s", char, output))
  endfor
  let @a = save
endfunction

" usage
:%call AppendAscii()

format json in vim

[!NOTE|label:references:]

:%!jq .

" or
:%!python -m json.tool

multiple repalce in silent mode

:silent! %s/old/new/g | %s/old2/new2/g

related commands:

  • :argdo : all files in argument list

  • :bufdo : all buffers

  • :tabdo : all tabs

  • :windo : all windows

reference:

:bufdo <command>
  • replace

    # regular
    :%s/<str>/<str_new>/ge
    
    # for all buffers
    :bufdo %s/<str>/<str_new>/ge | update
  • force the bufdo to continue without saving files via :bufdo!

close buffer when close window

  • commands

    :windo bd
    :%bd
    :silent clear
  • autocmd

    autocmd VimLeave * silent clear                                         " :windo bd
    autocmd VimLeave * silent :%bd

switch in buffers

  • next buffer: ctrl + ^

  • previous buffer: ctrl + 6

  • first: :1b<CR>

  • last: :$b<CR>

show ascii under cursor

[!NOTE|label:references:]

  • keyboard

    • ga

  • commands

    :as
    
    " or
    :ascii
    
    " or shortcut `ga` : https://til.hashrocket.com/posts/lsqojsbmmn-get-character-without-diacritical-mark-in-vim

open vim with specific line Number

[!NOTE|label:reference]

# last line
$ vim + /path/to/file

# specific line
$ vim +123 /path/to/file

" or https://til.hashrocket.com/posts/joyovn3pau-go-to-file-with-line-number
$ vim /path/to/file:123
N|

" i.e.: go to 15th column of current line
15|

jumplist

[!TIP|label:tips:]

  • :help ''

  • `:help ```

" check jump list
:jumps

" clear jump list
:clearjumps

" jump back https://til.hashrocket.com/posts/ue7f2hf8x2-jump-back-
''

" jump previous
``
  • relative path:ctrl + g or

    :file
  • :echo @%
  • print full path

    :echo expand('%:p')
:%s/></>\r</g
gg=G

encryption with Vim

set cryptmethod=blowfish2
  • encrypt

    $ vim -x file.txt
    :w!
    
    # or
    :set key=<password>
    :wa!
  • decrypt

    $ vim -X file.txt
    
    " or in vim
    :set key=
    :wa!

open vim with specific commands

[!NOTE|label:references:]

  • using vim to format git commit message

$ vim -c "set ft=gitcommit" \
      -c "setlocal buftype=nofile" \
      -c "setlocal bufhidden=unload" \
      -c "setlocal noswapfile" \
      -c "setlocal nowrap" \
      -c "setlocal nobuflisted" \
      -c "setlocal nomodifiable" \
      -c "setlocal nospell" \
      -c "setlocal foldmethod=expr" \
      -c "setlocal foldexpr=getline(1)" \
      -c "normal! ggVGgq" \
      -c 'silent execute "%s/--COMMIT-- //g"' \
      -c 'silent execute "%s/\x1b\[[0-9;]*m//g"' \
      -c 'silent execute "%s/\x1b\[[0-9;]*K//g"' \
      -c 'silent execute "%s/\x1b\[[0-9;]*G//g"' \
      -c 'silent execute "%s/\x1b\[[0-9;]*h//g"' \
      -c 'silent execute "%s/\x1b\[[0-9;]*l//g"' \
      -c 'silent execute "%s/\x1b\[[0-9;]*r//g"' \
      -c 'silent execute "%s/\x1b\[[0-9;]*m//g"' \
      "${files}"

config

get platform

[!NOTE|label:references:]

" to avoid `system('uname')` issue in powershell/gvim/cmd
" previous solution: https://stackoverflow.com/a/57015339/2940319
"   let uname = substitute(system('uname'),'\n','','')
"   if uname == 'Linux'
" to avoid `Can't open file /proc/version` in MacOS using:
" - `has('linux')` instead of `has('unix')`
" - `has('unix') && !has('macunix')` if `has('linux')` not supported
function! IsWSL()
  if has( 'linux' )
    let lines = readfile( '/proc/version' )
    if lines[0] =~ 'Microsoft'
      return 1
    endif
  endif
  return 0
endfunction

function! IsWindows()
  return ( has('win32') || has('win64') )
endfunction

function! IsLinux()
  return has('unix') && has('linux') && !has('macunix')
endfunction

function! IsMac()
  return has('macunix')
endfunction

disable vim beep

# ~/.vimrc
set noerrorbells novisualbell visualbell                            " ┐ turn off
set t_vb=                                                           " ┘ error/normal beep/flash

pastetoggle

[!NOTE|label:references:]

  • :set paste

  • :set nopaste

  • :set pastetoggle=<F2>

  • details

set iskeyword-=_
nnoremap <leader>e :set iskeyword-=_<cr>diw:set iskeyword+=_<cr>i

run vim commands in terminal

[!NOTE|label:manual:]

$ man vim
...
OPTIONS
  +{command}
  -c {command}
             {command} will be executed after the first file has been read.  {command} is interpreted
             as an Ex command.  If the {command} contains spaces it must be enclosed in double quotes
             (this depends on the shell that is used).  Example: Vim "+set si" main.c
             Note: You can use up to 10 "+" or "-c" commands.

  --cmd {command}
             Like using "-c", but the command is executed just before processing any vimrc file.  You
             can use up to 10 of these commands, independently from "-c" commands.
$ vim -es -c "set ff? | q"
  fileformat=unix
$ vim +commandHere filename

# or
$ vim +linenumber filename
  • $ vim +linenumber filename -c 'normal zR'
export PAGER="/bin/sh -c \"unset PAGER;col -b -x | \
       vim -R -c 'set ft=man nomod nolist' -c 'map q :q<CR>' \
       -c 'map <SPACE> <C-D>' -c 'map b <C-U>' \
       -c 'nmap K :Man <C-R>=expand(\\\"<cword>\\\")<CR><CR>' -\""
  • additional highlight

    " DrChip's additional man.vim stuff
    syn match manSectionHeading "^\s\+[0-9]\+\.[0-9.]*\s\+[A-Z].*$" contains=manSectionNumber
    syn match manSectionNumber "^\s\+[0-9]\+\.[0-9]*" contained
    syn region manDQString start='[^a-zA-Z"]"[^", )]'lc=1 end='"' contains=manSQString
    syn region manSQString start="[ \t]'[^', )]"lc=1 end="'"
    syn region manSQString start="^'[^', )]"lc=1 end="'"
    syn region manBQString start="[^a-zA-Z`]`[^`, )]"lc=1 end="[`']"
    syn region manBQSQString start="``[^),']" end="''"
    syn match manBulletZone transparent "^\s\+o\s" contains=manBullet
    syn case match
    syn keyword manBullet contained o
    syn match manBullet contained "\[+*]"
    syn match manSubSectionStart "^\*" skipwhite nextgroup=manSubSection
    syn match manSubSection ".*$" contained
    
    hi link manSectionNumber Number
    hi link manDQString String
    hi link manSQString String
    hi link manBQString String
    hi link manBQSQString String
    hi link manBullet Special
    hi manSubSectionStart term=NONE cterm=NONE gui=NONE ctermfg=black ctermbg=black guifg=navyblue guibg=navyblue
    hi manSubSection term=underline cterm=underline gui=underline ctermfg=green guifg=green

reference:

overview of multi items

pattern
magic
nomagic
matches of the preceding atom

/star

*

\*

0 or more   (as many as possible)

/\+

\+

\+

1 or more   (as many as possible)

/\=

\=

\=

0 or 1   (as many as possible)

/\?

\?

\?

0 or 1   (as many as possible)

/\{

\{n,m}

\{n,m}

n to m   (as many as possible)

\{n}

\{n}

n   exactly

\{n,}

\{n,}

at least n   (as many as possible)

\{,m}

\{,m}

0 to m   (as many as possible)

\{}

\{}

0 or more   (as many as possible. same as *)

/\{-

\{-n,m}

\{-n,m}

n to m   (as few as possible)

\{-n}

\{-n}

n    exactly

\{-n,}

\{-n,}

at least n   (as few as possible)

\{-,m}

\{-,m}

0 to m   (as few as possible)

\{-}

\{-}

0 or more   (as few as possible)

overview of ordinary atoms

pattern
magic
nomagic
matches

/^

^

^

start-of-line (at start of pattern) /zero-width

/\^

\^

\^

literal '^'

/\_^

\_^

\_^

start-of-line (used anywhere) /zero-width

/$

$

$

end-of-line (at end of pattern) /zero-width

/\$

\$

\$

literal '$'

/\_$

\_$

\_$

end-of-line (used anywhere) /zero-width

/.

.

\.

any single character (not an end-of-line)

/\_.

\_.

\_.

any single character or end-of-line

/\<

\<

\<

beginning of a word /zero-width

/\>

\>

\>

end of a word /zero-width

/\zs

\zs

\zs

anything, sets start of match

/\ze

\ze

\ze

anything, sets end of match

/\%^

\%^

\%^

beginning of file /zero-width E71

/\%$

\%$

\%$

end of file /zero-width

/\%V

\%V

\%V

inside Visual area /zero-width

/\%#

\%#

\%#

cursor position /zero-width

/\%'m

\%'m

\%'m

mark m position /zero-width

/\%l

\%23l

\%23l

in line 23 /zero-width

/\%c

\%23c

\%23c

in column 23 /zero-width

/\%v

\%23v

\%23v

in virtual column 23 /zero-width

  • every 3rd

    \(.\{-}\zsfoo\)\{3}
  • the 3rd

    ^\(.\{-}\zsPATTERN\)\{3}
  • ^\(.\{-}\zsPATTERN\)\{N} == > \v^(.{-}\zsPATTERN){N}

  • ^\(.\{-}\zs=\)\{N} == > \v^(.{-}\zs\=){N}

NOTICE: after using \v the = should using \= instead

characters

[!NOTE|label:references:]

first
char
mode
max nr of chars
max value

(none)

decimal

3

255

-

o or O

octal

3

377

(255)

x or X

hexadecimal

2

ff

(255)

u

hexadecimal

4

ffff

(65535)

U

hexadecimal

8

7fffffff

(2147483647)

  • show all digraphs

    [!NOTE|label:references:]

    :redir @a | silent digraph | redir END | new +setl\ buftype=nofile\ bufhidden=wipe | put! a
    
    : or
    :redir @a | silent digraph | redir END | new +setl\ buftype=nofile\ bufhidden=wipe | put! a | on

insert unicode

  • via hex

    [!NOTE|label:references:]

    • i.e.:

      • steps:

        • esc : return to normal mode ( optional )

        • i || o || a || ... : insert mode

        • ctrl + v

        • insert u2b38 or u2911 : 4 digits using u

    • emoji

      • steps:

        • esc : return to normal mode ( optional )

        • i || o || a || ... : insert mode

        • ctrl + v

        • insert U2b38 or U2911 : >4 digits using U

  • via digraph char

    [!NOTE|label:refrences:]

    • i.e.:

      • 3c ㈢ 12834

      • 4c ㈣ 12835

      • 5c ㈤ 12836

      • steps:

        • esc : return to normal mode ( optional )

        • i || o || a || ... : insert mode

        • ctrl + k

        • insert 3c or 4c or 5c

      ![i_ctrl-k](../screenshot/vim/digraphs -i_ck-1.gif)

micro

[!NOTE|label:references:]

stop macro at the end of line

:let a=line('.')
<....>                  " do micro
:if line('.')==a | exec 'normal @q' | endif
"                                |
"                                v
"                           micro name

others

[!NOTE|label:references:]

[!NOTE|label:references:]

    • binary on

    • textwidth 0

    • modeline off

    • expandtab off

:mksession! <filename>
  • or

    $ vim -S <filename>

comments

[!NOTE|label:references:]

statueline

[!NOTE|label:references:]

  • sample

    if has('statusline')
      set laststatus=2
      set statusline=%#User2#%m%r%*\ %F\ %y,%{&fileformat}
      " set statusline+=\ %{FugitiveStatusline()}                     " set statusline+=\ %{fugitive#statusline()}
      set statusline+=%=\ %-{strftime(\"%H:%M\ %d/%m/%Y\")}\ %b[A],0x%B\ %c%V,%l/%L\ %1*--%n%%--%*\ %p%%\ |
    endif

ctags

[!NOTE|label:references:]

  • groovy

# Generates ctags.
#   Usage: exfind folly,common cpp,h,thrift | genctags
function genctags () {
  ctags --c++-kinds=+p --extras=+q -L -
}
$ vim scp://username@host//path/to/somefile

Options: ,

Events: , , ,

Highlight groups: ,

|

without space: gJ or

and use: for f in GetFiletypes() | echo f | endfor

to

When the option is switched on (also when it was already on):

in mode and mode is disabled

are disabled

is reset

is reset

is reset

is reset

is reset

is reset

is reset

is set to 0

is set to 0

is set to 0

is made empty These options keep their value, but their effect is disabled:

is used like it is empty

:

|

2b38 :

2911 :

1F92A :

1F926 :

binary mode by

* Vim help files
* Vim Cheat Sheet
* vim : tip
* vimtricks
* Best Vim Tips
Vim run autocmd on all filetypes EXCEPT
Trigger OptionSet autocommand on entering diff mode
How to execute a function when a diff closes
How to change editor options when switching to diff mode?
#1545 - OptionSet diff is not invoked on closing the diff window
change cursor shape in diff mode
disable cursor line in diff mode
Nvim_terminal_emulator
'modified'
'scrollback'
TermOpen
TermEnter
TermLeave
TermClose
hl-TermCursor
hl-TermCursorNC
autocmd-intro
How to tell when in terminal mode?
Why neovim's terminal is differ from vim's terminal?
Map a key on a terminal buffer whose corresponding job is already finished
buftype
fabi1cazenave/termopen.vim
How to create in Terminal mode?
nomainchapou/nostalgic-term.nvim
to display a terminal split at the very bottom of vim window
startinsert
keymap
open terminal in top pannel
open terminal when vim start
:j!
Capitalize words and regions easily
Switching case of characters
* Switching case of characters
* Changing case with regular expressions
Simple calculations with Vim's expression register
delete line without copy to default register
Vim registers: The basics and beyond
How to delete (not cut) in Vim?
Registers
:@ Execute the contents of register
ctrl-k delete to end of line in command mode
g ctrl-g
paste command result to vim
Open the output of a shell command in a split pane
How to insert the result of a command into the text in vim?
:r! :read!
search (in)sensitive
7. Ignoring case in a pattern
"Find next" in Vim
sort lines
How to sort using visual blocks
Reverse sort lines in Vim
list all filetype
or
newline
Why is \r a newline for Vim?
Vim save highlight info screen to file
:redir
Capture ex command output
How to redirect ex command output into current buffer or file?
* vim tips: Capture ex command output
or
TabMessage
Using tab pages
How to format a JSON file in vim
How to format JSON file in Vim
run command in multiple buffers
Search and replace in multiple buffers
various.txt
:as or :ascii
VimTricks : Inspect Character Under Cursor in Vim
Edit A File Starting On The Last Line
Edit A File At A Specific Line Number In Vim
navigate to Nth column
print path
print filename
format html
How to detect the OS from a Vim script?
zeorin/dotfiles/.vimrc
Automatically set paste mode in Vim when pasting in insert mode
option.txt paste
'paste'
mapping
Insert
Command-line
abbreviations
'autoindent'
'expandtab'
'hkmap'
'revins'
'ruler'
'showmatch'
'smarttab'
'softtabstop'
'textwidth'
'wrapmargin'
'varsofttabstop'
'cindent'
'formatoptions'
'indentexpr'
'lisp'
'smartindent'
Change up to next underscore "_" in vim
vim open file and go to specific function or linenumber
without fold
using vim as a man-page viewer under unix
vim regex
vim pattern
magic
matches the N pattern
\v: the following chars in the pattern are "very magic"
* digraph.txt:digraph-table
* :help i_CTRL-V
* :help i_CTRL-K
Vim Digraphs and Ligatures
Vi(m) tip #2: Entering greek/math symbols using vim digraphs
Is there a way to search inside the digraphs in Vim
youtube : Input Special / Foreign / Non-Keyboard Characters - Vim Tips (2)
vimticks : Insert special • characters
:help i_CTRL-V_digit
Unicode Chart
List of Unicode characters
List of Unicode Symbols: Complete Unicode Character Table on One Page
⬸ : Leftwards Arrow with Dotted Stem
⤑ : Rightwards Arrow with Dotted Stem
🤪 : Grinning Face With One Large And One Small Eye Emoji
🤦 : Face Palm Emoji
:help digraph-table
:help i_ctrl-k
How do I stop a recursive macro at the end of the line?
Insert current date or time
Insert current directory name
Insert current filename
Insert line numbers
To switch back to normal mode automatically after inaction
Using Git from Vim
Word count
startup-options
:help edit-binary
-b
save sessions resume later
How to Open Files with Vim
Command line tricks
Comment Lines according to a given filetype
Comment lines in different filetypes
Comment your code blocks automatically
Insert comment boxes in your code
Insert current date or time
Build your own Vim statusline
vim-airline
* preservim/tagbar
kornicameister/dotfiles/ctags.d
mfwarren/.ctags for groovy
ik5/dotfiles/.ctags
aiya000/dotfiles/.ctags.d
dansomething/dotfiles
groovytags
sw-samuraj/vim-gradle
vim-scripts/vim-gradle
#84 groovy support? : Put this in ~/.ctags
genctags
edit file in remove server
mode
diff mode
terminal mode
shortcuts
combine multiple lines with or without space
Capitalize words and regions easily
Switching case of characters
counter
insert vim expression
delete line without copy to default register
ctrl-k delete to end of line in command mode
g ctrl-g
commands
paste command result to vim
search (in)sensitive
search in visual mode
sort lines
list all filetype
newline
redirect cmd
insert hex code
format json in vim
multiple repalce in silent mode
run command in multiple buffers
close buffer when close window
switch in buffers
show ascii under cursor
open vim with specific line Number
navigate to Nth column
jumplist
print path
format html
encryption with Vim
open vim with specific commands
config
get platform
disable vim beep
pastetoggle
Change up to next underscore "_" in vim
run vim commands in terminal
vim open file and go to specific function or linenumber
using vim as a man-page viewer under unix
vim regex
vim pattern
overview of multi items
overview of ordinary atoms
matches the N pattern
characters
micro
stop macro at the end of line
others
startup-options
save sessions resume later
How to Open Files with Vim
comments
statueline
ctags
edit file in remove server
* iMarslo : redirect cmd
* iMarlso : show ascii under cursor
* iMarslo: unicode
* iMarslo: unicode in bash
J-gJ
vim calculator
vim ctrl-r insert expression
g ctrl-g
vim-paste-command-output
search-case-sensitive
select until find
sort lines
sort lines
redir to debug
get hex code of char
ascii
regex every third
regex every third
i_ctrl-v u
i_ctrl-v U
stop recursive macro at the end of line