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

Resources

Videos

    ​Derek Wyatt Vim Videos - The first
    time I came across their videos was on global commands - Globals, Command Line and Functions.
    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 Hurrell - 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 xmodmap based method for mapping for this.
      1
      ! Swap caps lock and escape
      2
      remove Lock = Caps_Lock
      3
      ! keysym Escape = Caps_Lock
      4
      keysym Caps_Lock = Escape
      5
      add Lock = Caps_Lock
      6
      ​
      7
      ! Press both Shift keys to get Caps_Lock
      8
      keycode 50 = Shift_L Caps_Lock Shift_L Caps_Lock
      9
      keycode 62 = Shift_R Caps_Lock Shift_R Caps_Lock
      Copied!
    Appending result from an external command to the buffer - https://vim.fandom.com/wiki/Append_output_of_an_external_command​
    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 '.'
    1
    " settings for tabs
    2
    :set tabstop=2 shiftwidth=2 expandtab
    3
    " convert the existing buffer
    4
    :retab
    Copied!
    Another option to would be to reindent the whole file with gg=G.
    1
    set mouse=a
    Copied!
    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,
    1
    vim $(fd Dockerfile ~/Code)
    Copied!
    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.
    1
    fd Dockerfile ~/Code | vim -
    2
    ​
    3
    # Then open files one by one based on the contents (which could be empty if
    4
    # the search results are empty). Opening buffers for file locations is a
    5
    # pretty easy in Vim with Vim unimpared commands like `gf` in normal mode
    Copied!
    Write a file as superuser,
    1
    :w !sudo tee %
    Copied!
    ​Vim regex​
Last modified 1yr ago
Copy link