macvim-dev / macvim-dev/macvim

Ability to change what happens when pasting with Cmd+v the editor while still being able to use Cmd+v to paste in dialogs

Đang mở
#1,505 7 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Input
Ngôn ngữ chính
Vim Script
Star
7.9k
Fork
691
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Is your feature request about something that is currently impossible or hard to do? Please describe the problem.

I'm trying to customize paste behavior in MacVim in insert mode, to add come <C-g>u sequences to create undo points before and after the pasted text.

I can do that with an inoremap <D-v>. But in order for <D-v> to make it to the Vim input processing, it can't be bound in the MacVim menu system to the paste: action. So the folks at SuperUser suggest:

macmenu Edit.Paste key=<nop>
noremap <D-v> "*P
cnoremap <D-v> <C-r><C-o>*
inoremap <D-v> <C-g>u<C-r><C-o>*

But if you do that, then paste doesn't work in dialogs and other non-Vim UI elements insider MacVim, such as the graphical find dialog. As noted in the MacVim help on customizing the menu:

(E.g. the menu item "Edit.Paste" must be bound to the action "paste:" otherwise pasting won't work in dialogs since that is the action that instructs them to paste something.)

And I can't find any documentation on how to either change what happens when a paste: action is received by the Vim layer, or to set what happens when a <D-v> is sent to the GUI layer when it's not bound to a menu option.

So I'm not able to achieve the configuration where pressing Command+v creates undo points around the pasted text in Vim's insert mode, but also still works on text boxes in the GUI.

Describe the solution you'd like

My ideal approach would be to have paste: reach the Vim core exactly as if <D-v> were being typed, so that remapping <D-v> with inoremap would Just Work without having to unbind it from the menu item.

Describe alternatives you've considered
Other approaches would be:

  • Providing a command to control what MacVim actions like paste: do when they reach the Vim level.
  • Providing an option on the macmenu command to set key sequences to be issued in Vim before/after the action is processed.
  • Providing a mode-specific map-like command to map keys in the "mode" of having a dialog box selected, so that you could <something>noremap <D-v> to :macaction paste: and have that work in the dialogs. This might be totally impossible since then Vim internals would have to process all the keypresses in the dialogs.
  • Documenting some already-existing way to customize what the paste: action does by overwriting/replacing some VimScript function it already invokes.

Additional context
I only barely know enough about Vim input processing to articulate what I want to achieve, so it's possible I'm missing something obvious about how pasting works in Vim.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với phần trợ giúp của MacVim về việc tùy chỉnh menu, đặc biệt là mục Edit.Paste và hành động paste: của mục đó, sau đó lần theo cách hành động này đi tới quá trình xử lý đầu vào của Vim và các hộp thoại GUI. So sánh hành vi hiện có của macmenu, inoremap, cnoremap và macaction. Hoàn thành có nghĩa là Cmd+V có thể được tùy chỉnh trong chế độ chèn của Vim mà vẫn dán được trong các hộp thoại đồ họa.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
macos, vim
Lĩnh vực
desktop
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.