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
  • useful commands
  • Tabularize

Was this helpful?

  1. vim
  2. plugins

usage

PreviouspluginsNextother plugins

Last updated 1 year ago

Was this helpful?

useful commands

command! -nargs=0 -bar -range=% Reverse
    \       let save_mark_t = getpos("'t")
    \<bar>      <line2>kt
    \<bar>      exe "<line1>,<line2>g/^/m't"
    \<bar>  call setpos("'t", save_mark_t)
nnoremap <Leader>r :Reverse <bar> nohlsearch<CR>
xnoremap <Leader>r :Reverse <bar> nohlsearch<CR>

command! -nargs=0 DocTocUpdate execute 'silent !/usr/local/bin/doctoc --notitle --update-only --github --maxlevel 3 %' | execute 'redraw!'
command! -nargs=0 DocTocCreate execute 'silent !/usr/local/bin/doctoc --notitle --github --maxlevel 3 %' | execute 'redraw!'
command! -nargs=1        First execute                           'Tabularize /^[^' . escape(<q-args>, '\^$.[?*~') . ']*\zs' . escape(<q-args>, '\^$.[?*~')
command! -nargs=1 -range First execute <line1> . ',' . <line2> . 'Tabularize /^[^' . escape(<q-args>, '\^$.[?*~') . ']*\zs' . escape(<q-args>, '\^$.[?*~')
command! -nargs=0        Iname execute 'echo expand("%:p")'

[!TIP|label:references:]

specifier
comments

l<N>

left-align (with N spaces padding)

r<N>

right-align (with N spaces padding)

c<N>

center-align (with N spaces padding)

:Tabularize /,/r1c1l0 means:

  • splitting fields on commas (:)

  • print everything before the first comma right aligned, then 1 space

  • then the comma center aligned, then 1 space,

  • then everything after the comma left aligned.

  • including the <sep>

    • align to left

      :Tabularize /<sep>
      • or

        :Tabularize /<sep>/l1
    • align to center

      :Tabularize /<sep>/r1c1l0
  • align without <sep>

    :Tabularize /<sep>\zs/<specifier>

align with the N pattern

i.e.: the second match (=)

    • align the first :

      :Tabularize /^[^:]*\zs:
      :Tabularize /:.*
    • [!NOTE] only for default left-alignemnt. Not support customized right/middle alignment. i.e.: /r1c1l0

      command! -nargs=1 -range First exec <line1> . ',' . <line2> . 'Tabularize /^[^' . escape(<q-args>, '\^$.[?*~') . ']*\zs' . escape(<q-args>, '\^$.[?*~')
  • align with 2nd matches

    :Tabularize /^\(.\{-}\zs=\)\{N}/
                 |
                `^` means start of the line
    • or with \v (very magic)

      reference:

      :Tabularize /\v^(.{-}\zs\=){N}/<specifier>
  • for every N matches

    : Tabularize /\(.\{-}\zs=\)\{N}/<specifier>
                 |
                 no `^` means every `{N}` matches
    • or

      :Tabularize /\v(.{-}\zs\=){N}/<specifier>

[!NOTE|label:pre condition:]

  • align the first : and last matches , as below:

[
  isRunning : proc.getOrDefault( 'run' , false ) ,
  name : proc.getOrDefault( 'name' , '') ,
  runningStage : proc.getOrDefault( 'stage' , ['all'] ) ,
  type : proc.type.split('^.*\\u00BB\\s*').last() ,
]
  • first :

    reference: via

    • /^[^;]*\zs:

    • /^[^;]*\zs:/r1c1l0

    • /^[^;]*/r1c1l0

    • /^[^:]*\zs:

      isRunning    : proc.getOrDefault( 'run' , false ) ,
      name         : proc.getOrDefault( 'name' , '') ,
      runningStage : proc.getOrDefault( 'stage' , ['all'] ) ,
      type         : proc.type.split('^.*\\u00BB\\s*').last() ,
    • /^[^:]*\zs/r1c1l0

         isRunning  : proc.getOrDefault( 'run' , false ) ,
              name  : proc.getOrDefault( 'name' , '') ,
      runningStage  : proc.getOrDefault( 'stage' , ['all'] ) ,
              type  : proc.type.split('^.*\\u00BB\\s*').last() ,
    • /^[^:]*\zs:/r1c1l0

         isRunning : proc.getOrDefault( 'run' , false ) ,
              name : proc.getOrDefault( 'name' , '') ,
      runningStage : proc.getOrDefault( 'stage' , ['all'] ) ,
              type : proc.type.split('^.*\\u00BB\\s*').last() ,
    • /^[^:]*/r1c1l0

        isRunning   : proc.getOrDefault( 'run' , false ) ,
          name      : proc.getOrDefault( 'name' , '') ,
      runningStage  : proc.getOrDefault( 'stage' , ['all'] ) ,
          type      : proc.type.split('^.*\\u00BB\\s*').last() ,
    • /^[^:]*:/r1c1l0:

        isRunning :  proc.getOrDefault( 'run' , false ) ,
          name :     proc.getOrDefault( 'name' , '') ,
      runningStage : proc.getOrDefault( 'stage' , ['all'] ) ,
          type :     proc.type.split('^.*\\u00BB\\s*').last() ,
  • last ,

    tips:

    • actually the pattern not matches with the final ,, but matches with )<.*> ,

    sample code:

       isRunning : proc.getOrDefault( 'run' , false ) ,
            name : proc.getOrDefault( 'name' , '') ,
    runningStage : proc.getOrDefault( 'stage' , ['all'] ) ,
            type : proc.type.split('^.*\\u00BB\\s*').last() ,
    • /)[^,]*\zs,

         isRunning : proc.getOrDefault( 'run' , false )       ,
              name : proc.getOrDefault( 'name' , '')          ,
      runningStage : proc.getOrDefault( 'stage' , ['all'] )   ,
              type : proc.type.split('^.*\\u00BB\\s*').last() ,
      • or even better align

        • :1,3Tabularize /, or :'<,'>Tabularize /,

             isRunning : proc.getOrDefault( 'run'   , false )   ,
                  name : proc.getOrDefault( 'name'  , '')       ,
          runningStage : proc.getOrDefault( 'stage' , ['all'] ) ,
                  type : proc.type.split('^.*\\u00BB\\s*').last() ,
        • :Tabularize /)[^,]*\zs,

             isRunning : proc.getOrDefault( 'run'   , false )     ,
                  name : proc.getOrDefault( 'name'  , '')         ,
          runningStage : proc.getOrDefault( 'stage' , ['all'] )   ,
                  type : proc.type.split('^.*\\u00BB\\s*').last() ,

: /^\s*\S\+\zs/l0c1l0

: /^\(.\{-}\zs=\)\{2}/l1l0

[!NOTE]

refer to

tabularize-3
Tabular cheatsheet
align with first space
help /zs
matches the N pattern
align on first matche
or
via vim cmd
:help \v
vim pattern: overview of ordinary atoms
align on specific symbol
Tabularize
useful commands
Tabularize
align with the N pattern
align on specific symbol
align the second = to left
tabularize
tabularize-5
align with the 2nd matches
tabularize-1
tabularize-2
tabularize-4