Git Product home page Git Product logo

vim-subversive's People

Contributors

astier avatar holesch avatar svermeulen avatar tek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

vim-subversive's Issues

Option to put substituted (by motion) text into default register ("")?

Hello, this might just be my favorite and most used plugin for the s-mappings that imitate the behavior of c, cc, C, d, dd and D, but I'm missing just one thing:

Similarly like c and d I would prefer if the default register was replaced by what was erased by s, so that I could quickly place that elsewhere by p or another s.

This would then be useful with dot-repeat (with tpope/vim-repeat) for rearranging parts of text. I'll make an example:

Given the mappings:
nmap s <Plug>(SubversiveSubstitute)
nmap ss <Plug>(SubversiveSubstituteLine)
nmap S <Plug>(SubversiveSubstituteToEndOfLine)

Current behavior:

Text: one, two, three, four, five, six

Command sequence from start of line: ywWswW.W.W.W.0.

Result: one, one, one, one, one, one

If s were to put erased text to default register:

Result: six, one, two, three, four, five

This would then make it work the exact same as c and d by default, at least in my mind.

Maybe this already exists as an option in this plugin, but I wasn't able to get it to work? Or it's easily achievable by a small tweak/mapping? I'm just asking for advice on how to get it to work like this.

Best wishes!

Problem with substituting over range

Hi,
I have a small problem with the substitution.
Whenever I want to substitute say all e's in a single word, it substitutes all e's in the line instead.

asciicast

Input was <leader>sliw

The problem also occurs with minimal config with only subversive installed.

Neovim version output:

NVIM v0.6.1
Build type: Release
LuaJIT 2.0.5
Compiled by builduser

Features: +acl +iconv +tui

Keymap config (lua):

vim.api.nvim_set_keymap("n", "ss", "<Plug>(SubversiveSubstituteLine)", {})
vim.api.nvim_set_keymap("n", "S", "<Plug>(SubversiveSubstituteToEndOfLine)", {})

vim.api.nvim_set_keymap("n", "<leader>s", "<Plug>(SubversiveSubstituteRange)", {})
vim.api.nvim_set_keymap("x", "<leader>s", "<Plug>(SubversiveSubstituteRange)", {})
vim.api.nvim_set_keymap("n", "<leader>ss", "<Plug>(SubversiveSubstituteWordRange)", {})

Substituting empty surrounds

Hi,

I cannot substitute "empty" inner surrounds such as "", () or []. This would be quite handy when trying to fill them with some value e.g. yanking a word Parameter and pasting it into these brackets by pressing si) (having the subversive binding on s, resulting in (Parameter)).

Thanks a lot!

Range functions without confirm don't work

Using Vim 9.0 these functions don't seem to work:

  • SubversiveSubvertRange
  • SubversiveSubvertWordRange

while these work:

  • SubversiveSubstitute
  • SubversiveSubstituteLine
  • SubversiveSubstituteRangeConfirm
  • SubversiveSubstituteToEndOfLine
  • SubversiveSubstituteWordRangeConfirm

If I do SubversiveWordRange in Visual mode, it fails silently and all the subsequent errors are also silent.

With bare minimum testrc the error is:

Error detected while processing function subversive#lineRangeMotion#selectRangeMotion[50]..<SNR>35_execRepeatableCommand:
line    2:
E16: Invalid range

My minimum testrc is:

set nocompatible
filetype on
filetype plugin on
filetype indent on
syntax on

call plug#begin()
Plug 'svermeulen/vim-subversive'
call plug#end()

let mapleader = " "

nmap s           <Plug>(SubversiveSubstitute)
nmap ss          <Plug>(SubversiveSubstituteLine)
nmap S           <Plug>(SubversiveSubstituteToEndOfLine)
nmap <Leader>s   <Plug>(SubversiveSubvertRange)
nmap <Leader>ss  <Plug>(SubversiveSubvertWordRange)
nmap <Leader>cs  <Plug>(SubversiveSubstituteRangeConfirm)
nmap <Leader>css <Plug>(SubversiveSubstituteWordRangeConfirm)
xmap <Leader>s   <Plug>(SubversiveSubvertRange)
xmap s           <Plug>(SubversiveSubstitute)
xmap p           <Plug>(SubversiveSubstitute)
xmap P           <Plug>(SubversiveSubstitute)
xmap <Leader>cs  <Plug>(SubversiveSubstituteRangeConfirm)

If I include Plugin vim-polyglot then the error is different:

Error detected while processing function subversive#lineRangeMotion#selectRangeMotion[50]..<SNR>64_execRepeatableCommand:
line    2:
E464: Ambiguous use of user-defined command: '[,']S/Plug/foo/wg

A motion to delete instead of replace

Sometimes you want to just delete some text rather than replace it with something. Currently, if you leave the prompt text empty it will interpret this as a cancel and do nothing.

Although you can pass the black hole register to the substitute motion to get this same effect, for example "_siwip so that might be enough

Bug: inccommand and nnoremap : ;

Using the following config:

" Leader Mappings
let mapleader = ","
set inccommand=split

" nnoremap ; :
nnoremap : ;

" Add bundles
call plug#begin('~/.vim/bundle/')

Plug 'svermeulen/vim-subversive'

" ie = inner entire buffer
onoremap ie :exec "normal! ggVG"<cr>

nmap <leader>e <plug>(SubversiveSubstituteWordRange)ie
call plug#end()

the plugin isn't working.

The use of feedkeys in e34bdc0 combined nnoremap : ; breaks to plugin.

[Feature Request] Substitution preview

Neovim has a feature called inccommand, which previews of (among others) the result of the :substitute command.

Would it be possible to support the same for the :SubversiveSubstitute* commands?

Registier selection

I would like to make those mapping working:

nmap R "+<plug>(SubversiveSubstitute)
nmap r <plug>(SubversiveSubstitute)
nmap RR "+<plug>(SubversiveSubstituteLine)
nmap rr <plug>(SubversiveSubstituteLine)

where the "+ has a special clipboard provider (nvim).

" Clipboard
let g:clipboard = {
      \ 'name': 'myClipboard',
      \     'copy': {
      \         '+': 'env COPY_PROVIDERS=desktop clipboard-provider copy',
      \         '*': 'env COPY_PROVIDERS=tmux clipboard-provider copy',
      \     },
      \     'paste': {
      \         '+': 'env COPY_PROVIDERS=desktop clipboard-provider paste',
      \         '*': 'env COPY_PROVIDERS=tmux clipboard-provider paste',
      \     },
      \ }
set clipboard=unnamed   " to/from * by default (tmux only, not system), use + to access host/OSC-52 clipboard
" Yank to system clipboard with Y
nmap YY "+yy
nmap Y "+y
vmap Y "+y

Source: Awesome clipboard provider from agriffis

Currently Riw == riw, Riw uses the "* provider instead of "+.

I18n issue

If using vim other than the English version, this line fails to catch the error when detecting yoink installation.
Snipaste_2019-08-23_18-24-10

Substitution with special characters does not get copied correctly

Repro steps:

  1. Enter the following: foo ^G<cr>bar. Should display as foo ^Mbar.
  2. Copy it to clipboard with yy
  3. Paste it with p
  4. Should paste properly as foo ^Mbar
  5. Try it with substitution operation by executing sj (assuming default mapping)
  6. Notice it displays as:
foo
bar

Multi line substitute swapping sometimes doesn't work correctly

Given the following buffer with cursor at ^

^one
two
three
four

jim
joe
frank
fred

Execute yjjjyj to copy two multiline yanks to yoink history. Move cursor:

one
two
three
four

^jim
joe
frank
fred

Hit sj<c-n> to perform a substitute then swap. Notice the buffer now appears as:

one
two
three
four

jim
one
two
fred

When it should be:

one
two
three
four

one
two
frank
fred

Setting clipboard to unnamed breaks substitute range.

Problem: When setting clipboard to unnamed <leader>siwip doesn't work as expected anymore. Removing the setting solves the issue.

Settings in .vimrc

set clipboard=unnamed
nmap <leader>s <plug>(SubversiveSubstituteRange)
xmap <leader>s <plug>(SubversiveSubstituteRange)
nmap <leader>ss <plug>(SubversiveSubstituteWordRange)

This is the error I get, if something happens to be yanked, instead of the error it works using the value of the register, instead of prompting the user.
image

How to make visual work with the Substitute Motion

The mappings provide the following:

" s for substitute
nmap s <plug>(SubversiveSubstitute)
nmap ss <plug>(SubversiveSubstituteLine)
nmap S <plug>(SubversiveSubstituteToEndOfLine)

Why there are no mappings to substitute the visual selection? Is this not working? Any idea how could it be fixed?

Substituting with newline (`\r`)

Thanks for the awesome plugin! I just recently came across it, but I'm loving it so far! I have a problem, though: I need to do some substitutions with newlines recently, but it didn't work.

With the standard mappings as described in the documentation I can e.g. visually select something I want to replace with newline (, was what I was working on at the moment), followed by <leader>sip to replace inside the current paragraph. This gives me the prompt and I can type \r. This replace with the text \r rather than a newline.

If I do the equivalent in vanilla vim (visual selection + :s/, /\r/g) it works just fine and newlines are correctly inserted.

Should I be typing something other than \r to insert newlines, or am I missing something stupid?

Making escape work to cancel exchange

Hi, great plugin, a nice replacement for the vim script alternatives. I was wondering if it could be made to respect esc when the exchange is initiated. I.e after the first cx[motion], instead of going off with cxc, to cancel to use . Something similar to how nvim surround works, which is also in a way a two step process (sometimes, depends on the action, but the idea is the same). Or I imagine something like a buffer local variable could be set to allow you to know if you are in the exchange state.

Using "inner" word object over multiple lines

image

Take the screenshot above. I want to substitute the contents of the string on the right file with the contents of the string on the left file.

If the string were on the same line, I'd just do a yi" on the right file and then do si" on the left file. This can't be done over multiple lines though, so instead I have to do the more tedious 29yy and then s29<CR>.

This might not be the plugin to address this problem, but I figured at a minimum if a solution was found, it'd be nice to put on the README or something like that (plus I already typed it out here too ๐Ÿ˜…).

[Feature Request] Default to group on `g:subversivePromptWithActualCommand`

With g:subversivePromptWithActualCommand set, substituting my_text leaves you with :'[,']s/\V\Cmy_text/|/gI (| being the cursor):

My suggestion, is to instead use :'[,']s/\V\C\(my_text\)/|/gI, automatically capturing my_text in a group.

This would allow users to more quickly complete with the current text with \1, for example:

:'[,']s/\V\C\(my_text\)/\1_is_amesome/gI
:'[,']s/\V\C\(my_text\)/this_is_\1/gI
:'[,']s/\V\C\(my_text\)/this_is_\1_and_now_way_longer/gI

Which will result in

my_text_is_amesome
this_is_my_text
this_is_my_text_and_now_way_longer

Subversive doesn't work correctly with langmap

Thanks for making this awesome plugin, it's one of the very best I know!

I've noticed that setting langmap (which can be used to swap keys in normal mode e.g. to accomodate a custom keyboard layout) breaks subversive. Here's a minimal configuration:

" Manage plugins with Vim-Plug (github.com/junegunn/vim-plug)
call plug#begin('~/.vim/plugged')
Plug 'svermeulen/vim-cutlass'
Plug 'svermeulen/vim-subversive'
call plug#end()

set langmap=de,DE,ed,ED

nmap s <plug>(SubversiveSubstitute)
nmap ss <plug>(SubversiveSubstituteLine)
nmap S <plug>(SubversiveSubstituteToEndOfLine)

Observed behavior:

  • cannot subsitute a word (sw, siW etc.)
  • substituting a line requires pressing s 4 times

Note that the langmap doesn't touch s key at all. I guess it has something to do with using d motion internally... I would be very grateful for a fix, subversive is awesome but I need to use langmap as well because I have a custom keyboard.

PS Vim version:

$ vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar 18 2020 18:29:15)
Included patches: 1-1453
Modified by [email protected]
Compiled by [email protected]

Breaks visual block mode paste

Repro steps:

  • Enter visual block mode with <c-v>
  • Select some number of rows/columns
  • Hit p
  • Observe that it doesn't work the same as vanilla vim. The pasted text is not repeated for each row

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.