terryma/vim-multiple-cursors

Keystrokes for the example gifs

terryma opened this issue · 10 comments

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 $)
  • pree 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

In example 2:

move to end of line with <C-e>

How is that? i_CTRL-E, inserts the character below the cursor... :(


Ah, never mind. I found it :P → https://github.com/terryma/dotfiles/blob/master/.vimrc#L763

Wow that's obscure - do you think this is worth adding to the docs?

" Ctrl-e: Go to end of line
inoremap <c-e> <esc>A 

How does that mapping even work, since you can't hit esc without cancelling the multiple cursors?

  1. please include the images in this ticket. 2. don't be disingenuous about the usefulness of your plugin if you have to have undocumented, unmentioned custom keybindings to complete the basic usage examples

@delvarworld Put this into your ~/.vimrc and Esc won't be canceling the multiple cursors:

let g:multi_cursor_exit_from_insert_mode = 0

Trying to follow example 2 but it simply does not work...please avoid using custom mappings or at least explain them!

Yeap, second example does not work. At least I did not managed to make it work for me.

The following revised keystrokes work for me for the second example if you don't use the special mappings that Terry has:

  • select the line with V
  • go to the end of the file with G
  • press 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 + A, type another " followed by ,
  • move to the beginning of the line with + I
  • hit , now all the words are on the same line
  • the rest is just normal Vim

@eapache For me that does not simply work. Do you have let g:multi_cursor_exit_from_insert_mode = 0? Actually, everything works accept of hit , now all the words are on the same line. Can not put all to the same line whatever I tried. However, when pressing delete key when cursors are at the end of lines, that makes number of lines twice smaller (so appends each second line - not every line - to the previous one, stripping ends of lines randomly).

Do you have let g:multi_cursor_exit_from_insert_mode = 0

Yes I do, I'd forgotten I even had that in my vimrc. I'm wondering if it should be the default, it seems very useful and I can't think of a reason it could cause problems?