terryma / vim-multiple-cursors Goto Github PK
View Code? Open in Web Editor NEWTrue Sublime Text style multiple selections for Vim
License: MIT License
True Sublime Text style multiple selections for Vim
License: MIT License
Hi,
great implementation of multiple cursors!
But with your plugin installed I can't move anymore with the cursor keys in normal mode. When I open a file, press "cursor down": vim go into insert mode, add the char "B" and add a new line after that and leaves me in insert mode. The j and k key work as expected.
Currently the plugin doesn't work for multikey commands in any mode once multicursor mode is started. Actions like ciw
in normal mode causes undetermined behavior since the plugin literally tries to fan out c
, i
, and w
individually at every virtual cursor location. Adding this support requires the plugin to be more intelligent with user input, deciding what to 'keep' vs what to 'fan out'.
How to reproduce:
Open an empty file
Type :set paste
Insert the following text:
foo
bar
Place cursor over "f"
Ctrl-v
then G
Ctrl-d
Enter insert mode (bang!)
Output:
foo
<Plug>(a)<Plug>(d)bar
it appears that every keystroke is being recorded right now. this is not consistent with the default undo behavior (which is that it undos everything you did in insert mode and reverts back to what it was in normal mode).
Hi,
I'm using vimified with vim-multiple-cursors.
It works fine, but it is too slow when I use more than 5-6 cursors at the same time. When I use about 20 cursors, it takes about 1 second for entering a single character in insert mode.
Is that normal behavior of the plugin ?
Thanks
If you have any tabs () in the same line and before where your cursor is located and you start the multiple cursors, It doesn't seem to count the tab key as a character and it selects the wrong block of text.
If I remove the tabs it works fine.
The multiple cursor mode will break
( I hope I get it correctly after I read the README and tried this plugin. )
Does it provide a method to simply mark all? Suppose I have 100 occurrences of a word I need to replace. Do I have to hit <C-n>
for 100 times? Thanks.
Currently the plugin's undo behavior is unpredictable, both inside and outside of multicursor mode. For example, text inserted into the buffer during multicursor mode is undone one character at a time in all virtual cursor locations. The correct behavior should be consistent with Vim - everything entered during insert mode before exiting back to normal mode is 1 undo block.
Implementing this might require some clever hackery with using undojoin
, further investigation is needed.
I open a file for editing, vim then goes into REPLACE mode as soon as I start typing movement commands. I disable vim-multiple-cursors and the problem goes away. Let me know if I can be of more help!
I haven't use sublime2 before, could you show me what key strokes are you using for each example?
Do the following:
Shift-V
jjjj
Ctrl-n
l (L)
The multiple cursors get set on each line as expected, then when you press L, the cursor on the top and bottom lines moves right (as expected), but the others remain "stuck". At this point the cursors aren't working at all and you need to Ctrl-n, ESC to get the editor looking normal again.
I press Control-n several times to select a word, the I press any of the movement keys and I see this:
Error while processing function 59_apply_user_input_next..385
E488: Trailing characters
E488: Trailing characters
but the movement works. This is what I have in my .vim directory:
/Users/julian/.vim
├── after
│ └── syntax
│ ├── haml.vim
│ └── html.vim
├── autoload
│ ├── pathogen.vim
│ ├── rails.vim
│ └── zencoding.vim
├── bundle
│ ├── ctrlp.vim
│ │ ├── autoload
│ │ │ ├── ctrlp
│ │ │ │ ├── bookmarkdir.vim
│ │ │ │ ├── buffertag.vim
│ │ │ │ ├── changes.vim
│ │ │ │ ├── dir.vim
│ │ │ │ ├── line.vim
│ │ │ │ ├── mixed.vim
│ │ │ │ ├── mrufiles.vim
│ │ │ │ ├── quickfix.vim
│ │ │ │ ├── rtscript.vim
│ │ │ │ ├── tag.vim
│ │ │ │ ├── undo.vim
│ │ │ │ └── utils.vim
│ │ │ └── ctrlp.vim
│ │ ├── plugin
│ │ │ └── ctrlp.vim
│ │ └── readme.md
│ ├── desert.vim
│ │ ├── README
│ │ └── desert.vim
│ ├── nerdtree
│ │ ├── README.markdown
│ │ ├── autoload
│ │ │ └── nerdtree.vim
│ │ ├── nerdtree_plugin
│ │ │ ├── exec_menuitem.vim
│ │ │ └── fs_menu.vim
│ │ ├── plugin
│ │ │ ├── NERD_tree.vim
│ │ │ └── nerdtree
│ │ │ ├── bookmark.vim
│ │ │ ├── creator.vim
│ │ │ ├── key_map.vim
│ │ │ ├── menu_controller.vim
│ │ │ ├── menu_item.vim
│ │ │ ├── opener.vim
│ │ │ ├── path.vim
│ │ │ ├── tree_dir_node.vim
│ │ │ └── tree_file_node.vim
│ │ └── syntax
│ │ └── nerdtree.vim
│ ├── supertab
│ │ ├── Makefile
│ │ ├── README.rst
│ │ └── plugin
│ │ └── supertab.vim
│ ├── vim-fugitive
│ │ ├── README.markdown
│ │ └── plugin
│ │ └── fugitive.vim
│ ├── vim-multiple-cursors
│ │ ├── CHANGELOG.md
│ │ ├── MIT-LICENSE.txt
│ │ ├── README.md
│ │ ├── assets
│ │ │ ├── example1.gif
│ │ │ ├── example2.gif
│ │ │ └── example3.gif
│ │ ├── autoload
│ │ │ └── multiple_cursors.vim
│ │ ├── doc
│ │ │ ├── multiple_cursors.txt
│ │ │ └── tags
│ │ └── plugin
│ │ └── multiple_cursors.vim
│ ├── vim-sensible
│ │ ├── README.markdown
│ │ └── plugin
│ │ └── sensible.vim
│ └── vim-surround
│ ├── README.markdown
│ └── plugin
│ └── surround.vim
├── compiler
│ └── coffee.vim
├── doc
│ ├── coffee-script.txt
│ ├── rails.txt
│ ├── tags
│ └── zencoding.txt
├── ftdetect
│ ├── coffee.vim
│ └── eco.vim
├── ftplugin
│ └── coffee.vim
├── indent
│ └── coffee.vim
├── plugin
│ ├── rails.vim
│ └── zencoding.vim
└── syntax
├── coffee.vim
└── eco.vim
35 directories, 69 files
And this is my vimrc
if v:progname =~? "evim"
finish
endif
set nocompatible
set backspace=indent,eol,start
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file
endif
set history=1000 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
map Q gq
inoremap u
syntax on
set hlsearch
augroup vimrcEx
au!
autocmd FileType text setlocal textwidth=78
autocmd BufReadPost *
\ if line("'"") > 1 && line("'"") <= line("$") |
\ exe "normal! g`"" |
\ endif
augroup END
set autoindent " always set autoindenting on
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
au BufRead,BufNewFile *.rabl setf ruby
set smartindent
set tabstop=2
set shiftwidth=2
set expandtab
set colorcolumn=120
set number
hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white
hi CursorColumn cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white
nnoremap c :set cursorline! cursorcolumn!
" Pathogen
call pathogen#infect()
call pathogen#helptags()
set statusline=%<\ %n:%f\ %m%r%y%=%-35.(line:\ %l\ of\ %L,\ col:\ %c%V\ (%P)%)
set mousehide
set ignorecase
set nowrap
set cursorline
set softtabstop=2
set background=dark
colorscheme desert
nmap : :%s/:([a-z_0-9]+)\s+=>/\1:/g
set autoread " Auto-reload buffers when file changed on disk
set backupdir=/.vim_backup " where to put backup files./.vim_temp " where to put swap files.
set directory=
let mapleader=","
In this image, i had chosen cd ~/vysakh0.github.io/
and pressed enter, it din do anything, when I started to move ( j ) I noticed it is selecting the text!
From :map i see multiple cursor is causing the issue, could some one sort this out please?
x <CR> * :<C-U>call multiple_cursors#new("v")<CR>
n <CR> * :call multiple_cursors#new("n")<CR>
How to reproduce:
test data
test
test
In normal mode
Select words "test"s with <C-n><C-n><C-n>
Press <S-v> (line visual mode)
Error message:
Error detected while processing function <SNR>153_apply_user_input_next..208..197..<SNR>153_highlight_region:
line 14:
E71: Invalid character after \%
E475: Invalid argument: \%13l\%>0v.*\%<-2147483648v.
Error detected while processing function <SNR>153_apply_user_input_next..208..197..<SNR>153_highlight_region:
line 14:
E71: Invalid character after \%
E475: Invalid argument: \%11l\%>0v.*\%<-2147483648v.
Error detected while processing function <SNR>153_apply_user_input_next..208..197..<SNR>153_highlight_region:
line 14:
E71: Invalid character after \%
I have the following mappings in my .vimrc
nmap <Up> ]<Space>
nmap <Down> [<Space>
these are loaded after the pathogen infect is called. When your (awesome) plugin is loaded, when I hit i get an A inserted on the line above my current line and put into insert mode. Same for down except the character is a B, left is a D, right is a C.
When I don't load your plugin everything is fine again.
Thoughts?
Haven't looked at the source yet to see how the plugin works, but it would appear that in order to ensure all the changes made during a multiple-cursors edit are undone/redone on a single undo/redo you need to use the :undojoin
command so that each small change is merged with the previous one... this should make things feel more natural and less painful when undoing the edit. It probably also gives you a pathway to undoing all the changes if the user decides to 'cancel' the edit with a Ctrl-C at some point.
Similar to Sublime Text's Find All -> Option-Enter feature:
After selecting some words with Control-n and typing c followed by some letters and hitting ESCAPE, typing u will only undo one letter at a time. Instead, it should probably undo the entire editing operation at once (perhaps using undo blocks?). Also, when the undo operation completes, the cursor should return to where the editing operation first began.
Many thanks for a great plugin!
When I've selected multiple areas with <C-n>
, if I attempt to enter insert mode by pressing i
, I get the following error message:
Key 'i' cannot be replayed at 11 cursor locations
Pressing i
again allows me to enter insert mode and works as expected.
Firstly, massive kudos for bringing this project to Vim. I'm hoping to help and contribute when I get time, but until then I'll file some issues just so they are recorded and somebody else may be able to fix them.
If you select multiple cursors, then press Ctrl-C, you'd expect the cursors to go away, much like pressing ESC. This is what happens when you are in visual mode and you press Ctrl-C. Instead, with multiple cursors what happens is all the cursors remain marked, even though they're not really active anymore. Pressing ESC at this point does nothing, and the only way to clear them is to do: Ctrl-n, ESC.
When marking a section, then typing :MultipleCursorsFind \n to find the newlines, everything breaks. On a file with two lines, selecting all, typing :MultipleCursorsFind \n i gives this response:
Key 'i' cannot be replayed on 122 cursor locations
Also, trying to fetch matches for linestart with ^ results in the same kind of behaviour.
Expected Behavior:
When I'm on a word and hit Cursor Next Key it will generate another cursor on the next matching word.
When I visually select multiple rows and hit Cursor Next Key it will generate a cursor for each row
Actual Behavior
Whenever Cursor Next Key is pressed I get the error:
EasyMotion: No matches
Reproduce
I've reproduced this in terminal vim 7.3.266 and mvim 7.3.
I've mapped n to Cursor Next Key to prevent conflicts with ctrlp plugin.
In terminal:
echo -e "one\none\none" > test.txt
mvim test.txt
with cursor on first "one" I hit Cursor Next Key and get:
EasyMotion: No matches
Enter visual mode and select all three rows of "ones", hit Cursor Next Key:
EasyMotion: No matches
Same thing with Visual Block
It would be great if vim-multiple-cursors could operate on any visually-selected region, and not just the word under the cursor.
if you have
function hello()
endfunction
and you select function
, and then <C-n>
, it will select endfunction
. endfunction should not be selected at all.
*
searches by whole keywords (h: star
). There should be an option in the plugin to allow similar behavior.
First, this is an awesome plugin!
Just wondering if it's possible to go into column mode by using up/down keys?
Would be nice to press
Ctrl+n Down Down Down Down
to quickly create cursors on four lines at the current column. I know about vim's column mode but this plugin is more wysiwig.
When I select a bunch of lines or words and press shift-i (What normally do in visual block mode) the plugin jumps to insert mode like it should but it also injects: ":call 74_apply_user_input_next('i')" into the code at every cursor.
I am using VIM version 7.3.429 and using the latest vim-multiple-cursors.
Thanks for the great plugin BTW! :)
Home/End/Insert not working in normal mode
When we have an example file content of:
example file with
approx four lines. example lines
should also containt
lots of example words.
I select the example
word on line number 1
like and the others too:
Then when I press multi_cursor_exit_key
my cursor location jumps to line number 4
:
But it should remain on line number 1
. This get's annoying when our file is very large and we have decide to not use multi cursors.
When using multiple cursors in insert mode, I'm seeing lots of errors with AutoComplPop plugin.
This plugin provides command to enable/disable itself: :AcpEnable
and AcpDisable
.
Is there a way to hook a custom command into vim-multiple-cursors that gets triggered on any transition into or out of insert mode? If not, how could I hack around this?
Seems like the plugin only responds to ESC itself when inside editing? I can't use my regular sequence (seen below) to get out of editing.
inoremap kj <ESC>
When changing words, if I type some characters and then hit backspace or ^H, nothing happens.
Any idea if my .vimrc may have some weird settings?
EDIT: updated the title with the actual option problem
Discovered this while testing something else. 'O' should insert a new line above every virtual cursor and goes in insert mode. Does not do that at the moment. 'o' on the other hand works.
If I select an entire line using visual line mode, then hit C-n
to add a cursor, I get unexpected behavior. Expected behavior should be that a new virtual cursor is added at the end of the line, and another search is performed on the buffer, similar to how visual mode works today.
The following mappings doesnt work as expected..
let g:multi_cursor_use_default_mapping=0
let g:multi_cursor_next_key="m"
let g:multi_cursor_prev_key="p"
let g:multi_cursor_skip_key="x"
let g:multi_cursor_quit_key=""
The README links to issue #12 for all the keystrokes used in the screencasts. That seems to 404 and I can't find it in the Issue history. I know I've read that issue before. Weird. Maybe GitHub is playing up, or has it been deleted (somehow)?
I begin selecting words with a ctrl-n
on the first "hello", and then hit ctrl-n
a few more times to select the rest. Note how the cursor on the first "hello" is one column too far to the right and misaligned from the others:
You can correct this problem if you remember to correct the first element before selecting the rest. That is, ctrl-n
, then j
to correct it, then the remaining ctrl-n
:
Now that everything is even i can type v
for normal mode, move to the beginning of the word, and insert the word "jonah" by doing ijonah
:
Of course I have g:multi_cursor_exit_from_insert_mode=0
so that I can escape and keep using all my cursors. But uh-oh, as soon as I hit escape, the bottom cursor gets misaligned from the others, going one space to the left:
p
with fp
<C-n>
c
to change<Esc>
to quit back to regular VimV
G
<C-n>
to add a cursor at the beginning of every line and move to normal modeI
to insert at the beginning of the line"
, move to end of line with <C-e>
, type another "
followed by ,
<C-j>
(this is a custom mapping of mine in Insert mode)<BS>
, now all the words are on the same linedt"
to delete everything until the first quoteL
to go to end of line (my custom mapping, default $
)r,
to replace the ]
with ,
H
(custom, default ^
), press f,
to find the first commav
to select ,
in visual mode, and mash on <C-n>
until the last occurrencec
followed by <CR>
to break the line into multiple lines<C-k>
(again my custom mapping)C-g<BS>
(custom mapping to move cursor in insert mode)C-e<BS>
jV
to visually select the second lineGk
to select all but the last line:
followed by the MultipleCursorsFind
commando
to toggle the cursor for each visual selectionp
to paste the content of the +
register (I have clipboard=unnamedplus
in my vimrc) to each virtual cursorIt's written in your README.md file as:
Pressing the key in Normal mode highlights the current word under the cursor in Visual mode and places a virtual cursor at the end of it.
Currently if we use multi_cursor_next_key
in normal mode, we have to press v
in order to get back to normal mode
. But it should not change the mode. Even in ST2, when select a word in normal mode, it stills remain in the normal (thus I can use normal mode commands liek I, A,etc..). I shouldn't use v
to get back (because I've started it in normal mode already)
I have mapped jj to escape in insert mode, but this is broken when multiple cursors is used. That is, the jj is interpreted as raw keystrokes.
Whenever I use this plugin it makes my vim-indent-guides disappear. This occurs whenever I use any of the actions:
multi_cursor_next_key
multi_cursor_prev_key
multi_cursor_skip_key
multi_cursor_quit_key
Thanks for the fantastic plugin!
I have the following lines in ~/.vimrc
and it doesn't accept them:
let g:multi_cursor_use_default_mapping=0
let g:multi_cursor_next_key="\<D-d>"
let g:multi_cursor_prev_key="\<D-u>"
let g:multi_cursor_skip_key="\<D-k>"
let g:multi_cursor_exit_key="\<Esc>"
The ctrlp vim plugin has a shorcut setting like let g:ctrlp_map = '<D-p>'
and it works like a charm. May be looking into this plugin for internal work could be helpful.
Minor:
a
ab
abc
Select the following lines visually, then move right twice, or left once. A change will be added to the undo history for no apparent reason.
ggVjj<C-n>h<ESC>
I have "i" mapped to "move right" (I think the standard for that is "l"). Nonetheless the plugin assumes that I have a default one and whenever I hit Edit (which is "s" in my case) after "C-n"ing couple positions, it inserts something like that:
:call <SNR>164_apply_user_input_next('i')
Is there any way to set it up correctly?
This is a weird one, and possibly intentional. Each press of Ctrl-n in Vim running in iTerm on OS X makes my Terminal sound the alarm. It's a harmless side-effect, but it just seems weird :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.