📈
wiki
  • Introduction
  • Books
    • Technical books
      • Elements of Programming
    • Psychology books
      • Mindset
  • Computer Science
    • Data Structures
      • Skip Lists
    • Algorithms
      • Hashing
      • Eller's Algorithm
    • Formal verification
      • Coq
      • Lean
      • TLA+
    • Garbage Collection
  • Programming
    • Functional programming
      • Functional data structures
      • Algebraic Effects
      • Dependent Types
        • Agda
        • Idris
      • Continuations
      • Category Theory
      • Total functional programming
      • Uniqueness Typing
      • GADT
      • Tagless Final
    • Concurrent Programming
      • Mutex
      • Semaphores
    • Parallel Programming
    • Systems Programming
      • Tagged pointers
    • Unicode
  • Competitive Programming
  • Source control
    • Git
  • Programming languages
    • Java
      • Java Garbage Collection
      • Java Performance
      • Java Modules
      • Graal
      • Java libraries
        • Spring
          • Spring Cloud
        • Guava
        • JUnit 5
        • Hamcrest
        • Logging
        • Google Auto
        • Lombok
        • JOOQ
        • duct-tape
        • args4j
        • Netty
    • Scala
      • Dotty
      • Specialization
      • Benchmarking Scala
      • Scala libraries
        • ZIO
    • Haskell
      • Haskell tools
        • Haskell tools
    • Lisp
      • Lisp books
    • Rust
      • Rust Async
    • C++
      • C++ libraries
        • Boost
        • Poco
        • Abseil
        • facebook folly
        • Intell TBB
      • C++ tools
        • Valgrind
        • CMake
        • Bazel
      • C++ books
    • C
      • C libraries
      • C books
    • Python
      • Testing
      • Cython
      • Python performance
      • Python libraries
        • requests
        • httpx
        • boto3
      • Python tools
        • pyenv
        • Pipenv
        • mypy
      • Python Cookbook
    • Prolog
      • Prolog Cookbook
    • Clojure
      • Clojure Cookbook
    • Julia
      • Julia libraries
        • DataFrames
  • Networking
    • TCP
    • UDP
    • QUIC
  • Mindfullness
    • Mediatation
      • Samatha
      • Vipassana
    • Flow
  • LLVM
    • Clang tools
  • Operating systems
    • Securing operating systems
      • Capsicum
  • Linux
    • Packaging
    • RPM
    • Deblian
      • Linux tools
    • APT package manager
    • sxhkd
    • playerctl
    • fish
    • w3m browser
      • NixOS
    • Nix package manager
  • macOS
    • macOS tools
      • Hammerspoon
  • Windows
    • Windows tools
      • AutoHotkey
  • CLI
    • tmux
    • screen
    • ripgrep
    • fd
    • bat
    • tldr
    • install
    • chflags
  • Technology
    • Search
      • Google
      • DuckDuckGo
      • Algolia
      • Elastic search
  • Databases
    • MySQL
    • PostgreSQL
    • Oracle
  • Text editors
    • Emacs
      • Emacs plugins
      • Org mode
    • Vim
      • Vim plugins
      • Text objects
    • Sublime Text
  • IDEs
    • IntelliJ IDEA
      • IDEA plugins
        • IdeaVim
  • Philosophy
    • Stoicism
      • Parallels with Buddhism
    • Buddhist philosophy
  • Learning
    • Spaced Repetition
      • Anki
  • History
    • People
      • Benjamin Franklin
  • Buddhism
    • Theravada
      • Dhammapada
      • Eight Worldly Concerns
    • Mahayana
      • Zen
        • Zen Koans
  • Psychology
    • CBT
    • Cognitive biases
  • Logic
    • Classical logic
    • Intuitionistic logic
    • Logical fallacies
  • Literature
    • Western literature
    • Oriental literature
      • Bhagavad Gita
    • Mythology
    • Aphorisms
  • Research
    • Problem solving
    • Questioning
    • Blogs
  • Papers
    • Computer Science
      • Higher-order logic programming in Prolog
      • The Rise of Worse is Better
      • Advantages and Disadvantages of a Monolithic Repository
      • Coccinelle
      • Total Functional Programming
      • Scalable Component Abstractions
    • Psychology
    • Literature
      • Euclid and Pāṇini
  • Courses
    • Computer Science
  • Devops
    • Ansible
    • Puppet
    • TerraForm
  • Life
    • Happiness
    • Journaling
  • Meetups
    • Rust Meetups
      • LDN Talks January, 2020
    • Scala Meetups
      • Scala in the City - January, 2020
    • Papers We Love
      • CREST/PWL Special Event - January, 2020
  • Sports
    • Running
      • Running books
      • Running shoes
    • Chess
      • Chess openings
    • Hiking
      • Outdooraholics
        • Box Hill, Surrey
  • Music
    • Classical
      • Western classical music
      • Indian classical music
    • Popular music
    • Sinhala music
    • Indian music
  • Podcasts
  • Movies
  • TV Series
  • Log
    • 2019 logs
      • September
      • October
      • November
      • December
    • 2020 logs
      • January logs
      • February logs
      • March logs
      • April logs
      • May logs
      • June logs
  • TIL
    • TIL in 2020
      • January
      • February
      • March
      • April
      • May
      • June
      • October
      • November
Powered by GitBook
On this page
  • Resources
  • Videos
  • Tips
  1. Text editors

Vim

PreviousOrg modeNextVim plugins

Last updated 5 years ago

I'm a big fan of modal editing and specifically Vim.

Resources

Videos

  • - The first

    time I came across their videos was on global commands - .

    This is a pretty good video to show some magic of Vim and it is very funny to boot! This would be my

    current video of choice to show someone the power of Vim at the hands of an advanced user.

  • - Greg's channel is not exclusively about Vim,

    but his channel full of Vim tips and tricks.

Tips

  • Map CapsLock to Esc

    • In Linux I've used based method for mapping for this.

      ! Swap caps lock and escape
      remove Lock = Caps_Lock
      ! keysym Escape = Caps_Lock
      keysym Caps_Lock = Escape
      add Lock = Caps_Lock
      
      ! Press both Shift keys to get Caps_Lock
      keycode  50 = Shift_L Caps_Lock Shift_L Caps_Lock
      keycode  62 = Shift_R Caps_Lock Shift_R Caps_Lock
    • On macOS this could be done via settings -

      .

  • Appending result from an external command to the buffer -

    read !<external command>

    For example, to get CPU info into the current buffer, read !cat /proc/cpuinfo.

  • Format JSON,

    • with python - :%!python -m json.tool

    • with jq tool - :%!jq '.'

  • Change Tabs to Spaces -

    " settings for tabs
    :set tabstop=2 shiftwidth=2 expandtab
    " convert the existing buffer
    :retab

    Another option to would be to reindent the whole file with gg=G.

  • Enabling mouse scroll support - .

    set mouse=a
  • Opening files based on a command line search. This is more of a command line tip, but I find this pattern to be quite useful. To open all Dockerfiles in a directory,

    vim $(fd Dockerfile ~/Code)

    Another adaptation of this pattern is to use a temporary vim buffer to put the search results and then open files based from buffer contents.

    fd Dockerfile ~/Code | vim -
    
    # Then open files one by one based on the contents (which could be empty if
    # the search results are empty). Opening buffers for file locations is a
    # pretty easy in Vim with Vim unimpared commands like `gf` in normal mode
  • Write a file as superuser,

    :w !sudo tee %

    How this works - .

Derek Wyatt Vim Videos
Globals, Command Line and Functions
Greg Hurrell
xmodmap
https://stackoverflow.com/questions/127591/using-caps-lock-as-esc-in-mac-os-x
https://vim.fandom.com/wiki/Append_output_of_an_external_command
https://stackoverflow.com/questions/426963/replace-tabs-with-spaces-in-vim
https://stackoverflow.com/questions/7225057/use-mouse-scroll-wheel-in-vim
https://stackoverflow.com/questions/2600783/how-does-the-vim-write-with-sudo-trick-work
Vim regex