back to listing index

terryma/vim-multiple-cursors

[web search]
Original source (github.com)
Tags: vim multi-line
Clipped on: 2018-07-14

Keystrokes for example gifs

J. Elliot Taylor edited this page 3 minutes ago · 4 revisions

Example 1

  • jump to p with fp
  • select the word under cursor with <C-n>
  • do that two more times for the other two occurrences in the function
  • press c to change
  • type the replacement
  • press <Esc> to quit back to regular Vim

Example 2

  • select the line with V
  • go to the end of the file with G
  • press <C-n> to add a cursor at the beginning of every line and move to normal mode
  • press I to insert at the beginning of the line
  • type ", move to end of line with <C-e>, type another " followed by ,
  • move every cursor down one line with <C-j>(this is a custom mapping of mine in Insert mode)
  • hit <BS>, now all the words are on the same line
  • the rest is just normal Vim

Example 3

  • press dt" to delete everything until the first quote
  • press L to go to end of line (my custom mapping, default $)
  • press r, to replace the ] with ,
  • go back to the beginning of the line with H (custom, default ^), press f, to find the first comma
  • press v to select , in visual mode, and mash on <C-n> until the last occurrence
  • press c followed by <CR> to break the line into multiple lines
  • move every cursor up one line with <C-k> (again my custom mapping)
  • delete the left quote with C-g<BS> (custom mapping to move cursor in insert mode)
  • go to end of line and delete right quote with C-e<BS>

Example 4

  • press jV to visually select the second line
  • press Gk to select all but the last line
  • type : followed by the MultipleCursorsFind command
  • press o to toggle the cursor for each visual selection
  • press p to paste the content of the + register (I have clipboard=unnamedplus in my vimrc) to each virtual cursor
Press h to open a hovercard with more details.