Code Monkey home page Code Monkey logo

vim-wordmotion's People

Contributors

chaoren 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-wordmotion's Issues

Dot repeat of `ciw` emits 'AOrInnerWordMotion' output if 'set noshowmode' is set.

Hello,

In the command line area I am seeing spurious output from this wordmotion plugin when set noshowmode is set.

Steps to produce the issue:

  • set noshowmode

  • Edit a file such as the following with the cursor positioned on the 1st line inside Bar:

FooBarFoo
BarFooBar
  • Do ciw to anything (e.g Car)

  • Move cursor to 2nd line inside Foo and hit dot . to repeat the change

  • Look in the command line area, spurious output will be emitted, in my case :call <SNR>10_AOrInnerWordMotion(v:count1, 'o', 1). Note, the actual change word operation is being performed correctly.

When showmode is set (aka the Vim default) there is no spurious output.

Maybe a <silent> directive is needed somewhere?

Thanks for a great plugin.

unexpected behavior for cw

Hi,

Let's say we have

foo bar

and then with cursor on first "o" of "foo" I press cw. After doing that, I'm getting

fbar

Without the plugin I was getting

f bar

Is that normal behavior?

THX, Alejandro

dW needs to match the behavior of dw

The behaviour that you mentioned in caveats section often becomes inconsistent because default dW still behaves like dE. So, it would be awesome if you can rebind W to work like w.

iw/aw do not respect visual block select without existing selection

Expected behaviour

When coupeling with iw, vim will treat visual block select like the normal visual select.

[cursor]

Camel[C]ase --> <C-v>iw --> Camel[Case]
CamelCas[e] --> <C-v>iw --> Camel[Case]

Observed behaviour

Vim merely jumps to the end of the word without selecting

Camel[C]ase --> <C-v>iw -> CamelCas[e]
CamelCas[e] --> <C-v>iw -> CamelCas[e]

Problem with accented characters

The first line is a sample line, I expect to reach the g with 3w (see the first line) but I actually have to use 5w since the accented character isn't taken into account as alphanumeric character.

abc déf ghi
^   ^   ^
^   ^^^ ^

Wrong behavior with folds

The behavior of the vim-wordmotion plugin doesn't correspond to the default vim w, b, e, ge motions interaction with folds.

Instead of opening fold (if foldopen option contains hor value, which is by default) vim-wordmotion moves cursor between words inside a closed fold without opening it.

Insert mode navigation

Trying to use <S-Left> and <S-Right>, <C-Left> and <C-Right> to navigate word boundaries while in insert mode and i'm back in the dark ages again!

I can't seem to find any easy example of how to map a keybinding to call the wordmotion navigation either.

Add `ge` motion

The four word (not WORD) motions are w, e, b, and ge. This plugin only works for the first three. It'd be great to have all four. Seems really simple to add. Thanks for the awesome plugin!

Wordmotion breaks change operator in macros

I recently wrote a macro like this:

ct(getFilter^[

to fix a piece of code like this:

let f = getConversion(...);

I'd expect it to give me:

let f = getFilter(...);

When I run this macro from the g, I instead get:

const f = call <SNR>71_WordMotion(v:count1, 'o', 'be', [])
tFilter(...)

When I run the macro commands manually in normal mode, the desired behavior occurs.

use vim default word definition for `WORD`

hey, thanks for the plugin. was looking for something like it and works like a charm. After using it for a while, I would prefer to use the default word definition for WORD. Is that config possible? I could not find it in the docs.

thanks!

Unexpected behaviour for dw on files with a shebang and no extension

On files with a shebang and no extension, dw seems to only delete a single character, rather than until the beginning of the next word.

Reproduction

Create four files (only the first one demonstrates the unintended behaviour, but the other three show (what I believe) the intended behaviour should be).

$ cat test1
#!/usr/bin/env python3
print('test')
$ cat test2
print('test')
$ cat test3.py
print('test')
$ cat test4.py
#!/usr/bin/env python3
print('test')

Reopen each file individually (opening all at the same time does not seem to invoke the unintended behaviour), and with cursor over the p in print, press dw. For test1, a single character is deleted, resulting in rint('test'). For all of test2, test3.py, and test4.py, the result is ('test').

Intended Behaviour

From my understanding, in all four cases, the result should be ('test'). Please correct me if I'm misunderstanding something.

step backwards (b) motion is not functioning properly

The motion to step backwards over/through words is no longer working after I recently updated the plugin. Previously it had stepped over camelCased words perfectly fine, but now the functionality (even default of stepping over entire words) is broken.

Now, When I press b the cursor moves backwards as if I were pressing the h key to step backwards letter by letter.

I haven't looked at the code to try and figure out a possible PR, but I did verify that it's this plugin by removing the plugin, which returned the b key back to the standard behavior.

A way to override Vim's W, B, E commands

First of all, massive thanks for this plugin. I have been using this plugin for years and I've always taken it for granted, being very surprised when I suddenly had to work in Vim without this plugin.

I've always wished for one more feature of this plugin and that would be the possibility to also override the default Vim's W, B, E, and possibly other commands.
The default behaviour is that Vim stops on the space character on these W, B, E commands. It would be great, in my opinion, if we could also override this behaviour so that Vim would stop on characters like -.,> but not on CamelCase snake_case and so on.

To give an example:

|CamelCaseWord->followed_by_snake_case

With the current behaviour, when I press W, the cursor moves the the end of the line.
What I would like is the cursor stopping on the dash character:

CamelCaseWord|->followed_by_snake_case

This would allow me to delete the first CamelCaseWord, for example, without deleting the rest. Now I have to press 3dw or 3 times dw.

Hopefully it makes sense what I mean.

around word does not select prior separator characters.

consider the scenario:
return true;

your cursor is somewhere on true and you use vaw.
default vim selects true and the prior space, this plugin just selects true.

it seems like you get this right in some scenarios, eg:
return true
here the space will be selected.

it happens with other delimiters than spaces too:
return my_var;
if your cursor is on var, it won't select the underscore.
return my_var
but do the same on this line, and the underscore is selected.

Unexpected behaviour for 'w' in snake_case_words

Hi,

After the implementation of #24 (which I'm still really grateful for!), I'm facing one issue when I use the 'w' motion in a snake_case_word.

I have set the wordmotion_spaces variable like this: let g:wordmotion_spaces = '-.<>()\[\]{}&*=!+"'''

When I'm at the beginning of the word and I press 'dw', I'd expect it to delete snake_ so only case_word would remain. But instead, it results with _case_word (notice the leading underscore).

If I also include an underscore symbol in the wordmotion_spaces variable, it works as expected, but it also defeats the purpose of #24. It also works if I don't set the wordmotion_spaces variable at all, because then it'll get set to _ by default.

Is this also one of the plugin's limitations or can this be fixed?

Hex color codes not recognized as single words

It's stated in README that the hex color codes are single words but e.g. #B2B2B2 is 6 words for me, same with lowercase. edit: That only happens when the color code is surrounded with quotes

Handle c_<C-R>_<C-W>

Pretty much title, it would be nice to use wordmotions in the command line insertion.

cw with count not work correctly

It seems that the count work as expected only when the cursor is placed at the end of the word:
2

I suspect that here

while l:count > 0
if l:count == 1 && l:cw
let l:flags .= 'c'
endif
call search('\m'.l:pattern, l:flags.'W')
let l:count -= 1
endwhile

shouble be

 if l:count == 1 && l:cw 
	let l:flags .= 'c' 
 endif 
 while l:count > 0 
 	call search('\m'.l:pattern, l:flags.'W') 
 	let l:count -= 1 
 endwhile 

And I've tested it and it works as expected after the modification, but I'm not sure whether it will break other stuff.

cw

ok so there are two things i have noticed.

thing 1:

 asdf_
^ cursor

cw here will change up to the underscore. default vim cw will change up to the a (it goes up to the word, not to the end of the word)

thing 2:
vims special case for cw (see https://old.reddit.com/r/vim/comments/26nut8/why_does_cw_work_like_ce/)
it would be nice if there was an option for the more canonical version of cw
eg:

asdf (
 ^ cursor

dw here would delete to the (
cw deletes up to (not including) the space, so it's like ce

Leading underscore as non-whitespace?

For private fields in a C++ class, I'm using the convention of a leading underscore, like _length or _id. With the default wordmotion settings, w moves to the first letter and will never stop on the underscore. In any other case, with the underscore in the middle or at the end of a word, that works fine. But it becomes very awkward for example to copy these private field identifiers because I can't w to the start of the word. Is there a way to configure wordmotion so that a leading underscore is a totally different character than an internal underscore? Or if not, can the position of the underscore be taken into account, so that the leading underscore becomes equivalent to a letter? Thanks for any suggestions.

<Plug> mappings

It's nice to be able to configure plugin-provided mappings using <Plug>, as opposed to config dictionaries. This way you can keep them in the same format as native mappings. If you're willing to incorporate <Plug> mappings, I can provide a PR that implements them. Shouldn't be too much code. There would also be an option g:wordmotion_disable_default_mappings that would disable the default logic for those who would rather set their own mappings with <Plug>.

Make w recognize - and CamelCase and W do what w used to do?

As the subject says. It looks like this should be possible with a big ilst in g:wordmotion_uppercase_spaces but it might be nice to have some easy way to do this (maybe just a var lying around that could be advertised in the docs). People who don't like lots of white space just never use W so it's likely a common want.

#define is considered two words

I've just tried vim-wordmotion. What an awesome plugin!

But I was wondering about the strange stop points in this line:

#define SCANCODE_TAB_KEY 15
^   ^   ^        ^   ^   ^

The reason might be that #def could be a short hex color code. Is this the intended behavior? I suppose there are more #defines in the world than mixed words starting with a short hex color code and going on with some unrelated letters :-)

Can I somehow define not to consider #define as two words? Kind of a blacklist?

Add ability to disable plugin while editing

Currently with the way the plugin is built, there is no way to disable it. For example, I created a function:

nnoremap <silent> <C-e> :call WordMotionToggle()<cr>
let s:wordmotion_enabled = 1
function! WordMotionToggle()
    if s:wordmotion_enabled
        let s:wordmotion_enabled = 0
        let g:wordmotion_prefix = 'invalid'
    else
        let s:wordmotion_enabled = 1
        let g:wordmotion_prefix = ''
    endif
endfunction

However this doesn't work because when WordMotion loads, it gets the global properties and sets them as local properties to the plugin before doing the motion mappings.

Can this plugin add some functionality that will allow you to disable it on the fly?

cw and dw revert to default vim behavior

Hi there and thanks for this super useful plugin! I'm fairly certain that the issue I'm having is specific to something in my setup, but I'm not sure what exactly is causing it. The issue is that w works as expected (as described in the README of this repo), but cw, ce, dw and de all revert to the default vim behavior. You can see my vimrc here. I'd love to hear confirmation that this is in fact not expected and any tips on how I could troubleshoot. Thank you!

Allow the user to set custom mappings

For example I'd like to have vim-wordmotion motion mapped to W, B, E, gE, aW, iW but I currently don't have any clean way to do so beside using a bogus custom prefix and then remapping the keys by hand.
I'd suggest to provide a way for the user to provide some custom mappings, maybe via a list/dictionary

Feature request: Toggling

I'd like to see toggling option in this plugin. For example, let user define a normal mapping to toggle on and off. It is more robust than having g:wordmotion_prefix, and adheres to vim's modal philosophy. Like, when I press predefined toggle map, I'm in wordmotion mode, press again, I exit wordmotion mode.

Meta word motions

Curious why ci<M-w> etc work as I'd expect, change default Vim word, but c<M-w> doesn't, the change is cancelled and cursor moves by default Vim word instead?

Error detected while processing function wordmotion#init

I have upgraded to version 5ba8453 (from some old one) in neovim 0.4.4 and on every launch I get:

Error detected while processing function wordmotion#init:                                                                      
line   40:                                                                                                                     
E699: Too many arguments

sometimes I also get:

Error detected while processing function wordmotion#motion:                                                                    
line   33:                                                                                                                     
E866: (NFA regexp) Misplaced * 

Any ideas?

Warn users if they copied the example configurations from the README

Hi there. Thanks for the useful plugin.

Though I noticed it doesn't work as I expect in the visual mode. If I press ve it still selects word as usual. This is my config

let g:wordmotion_nomap = 1
nmap w          <Plug>WordMotion_w
nmap b          <Plug>WordMotion_b
nmap gE         <Plug>WordMotion_gE
omap aW         <Plug>WordMotion_aW
cmap <C-R><C-W> <Plug>WordMotion_<C-R><C-W>

Could you guide me on how to resolve that? Thanks!

cw takes whitespace between words

Is it intentional to consume the whitespace between words? I'm getting myself frequently making mistakes because of this change, for example in |foo bar (cursor is |), I see that for dw it's indeed useful to delete whitespace, maybe, but for cw it doesn't make much sense, even more because it's inconsistent with ciw that whose purpose is to change word from inside the word, but it differs from behavior given that it doesn't consume whitespace, as in usual Vim.

Work with Surround plugin

This is a very useful plugin, especially when I have long_variable_name and need to change part of it. However, when working with surround, it is not very handy.

E.g.
[l]ong_variable_name1, long_variable_name2, ...
do ysw" and I got:
"long_"variable_name1, long_variable_name2, ...;
do ysW" and I got:
"long_variable_name1," long_variable_name2, ...

But most of the time, people want "long_variable_name1", and I cannot achieve this.

I'm wondering is there any workaround for this?

restore Vim's special case behavior for cw and dw

In readme you provides two example:

Vim:

	^foo [b]ar$ -> dw -> ^foo[ ]$
	^ baz$               ^ baz$

	^[f]oo bar$ -> cw -> ^[ ]bar$

This plugin:

	^foo [b]ar$ -> dw -> ^foo [b]az$
	^ baz$

	^[f]oo bar$ -> cw -> ^[b]ar$

and recommend to use nmap dw de to restore Vim's special case behavior.

But when cursor located in the last word of one line, the Vim origin dw behavior like d$. Neither dw nor de provide by this plugin has same effect.

So am I misunderstand what you post? And expected dw of this plugin have same effect, i.e. d$, when delete the last consecutive characters.

Thanks in advance.

Unexpected `g:wordmotion_prefix` behaviour for text objects

I configured let g:wordmotion_prefix = "," in my vimrc and expected text object bindings to change from iw and aw to i,w and a,w. Because I see i and a as the verbs and w or ,w as the nouns that the verbs operate on. Instead, the bindings were changed to ,iw and ,aw.

I'm using the following as a workaround:

let g:wordmotion_mappings = {
    \ 'w' : ',w',
    \ 'e' : ',e',
    \ 'b' : ',b',
    \ 'ge' : ',ge',
    \ 'iw' : 'i,w',
    \ 'aw' : 'a,w'
  \ }

wordmotion_prefix not working when using Lazy plugin manager

I've recently migrated to Lazy from Packer and it seems this has broken support to wordmotion_prefix.

You can reproduce this with the following minimal configuration:

-- bootstrap lazy
--
local lazy_path = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazy_path) then
   vim.fn.system({
      "git",
      "clone",
      "--filter=blob:none",
      "https://github.com/folke/lazy.nvim.git",
      "--branch=stable", -- latest stable release
      lazy_path,
   })
end
vim.opt.rtp:prepend(lazy_path)

-- plugins
--
require("lazy").setup({
   { "chaoren/vim-wordmotion" }, -- more precise word motion
})

vim.g.wordmotion_prefix = ","

Running :map w outputs:

o  w             <Plug>WordMotion_w
x  w             <Plug>WordMotion_w
n  w             <Plug>WordMotion_w

Mapping dw and cw causes long delay for dd.

Hi Chaoren - Thanks for this plugin!

When I cw on the word at the end of the line, vim-wordmotion includes the EOL, so I effectively join lines.

I think this is addressed in your README, where you say:

If you want to restore Vim's special case behavior with dw and cw, you can do this:

map dw de
map cw ce

Problem is, when I do that, dd takes a second before acting. Which is weird, because those mappings aren't for dd.

It's map dw de that's doing it. Without that, dd is instantaneous, like it's supposed to be.

Come to think of it, this doesn't have anything to do with vim-wordmotion, since I can replicate it without the plugin even loading. Perhaps you have some insight anyway?

This is with vim 7.4.1689.

provide a toggle command

First of all, awesome plugin, thank you.

Consider providing a :ToggleWordMotion command.

Rationale: prefixing wordmotion bindings commands with <leader> is not ideal. I more often need wordmotions defaults than not.

Temporarily disabling wordmotion would be faster if, for example, want to refactor var a=[a][b][a_really_huge_variable_using_the_normal_w_vim_motion];.

I'm leaving wordmotion with the default bindings and using :norm! ciw when I want to operate as described above. But that feels clunky.

Broken lsp rename

Hi there!

I just noticed that the plugin doesn't interact quite well with nvim's lsp lua vim.lsp.buf.rename().

Say for example I'm renaming nice_variable to cool_variable with the cursor over the word varible by launching the above mentioned command.
The prompt will ask what to replace variable with, instead of `nice_variable''.

Is this the expected behavior?

Request: Make hex color ocdes easier to move around (like `#0f0f0f`)

Hi! This is a great plugin, and has made vim word motions work way better for me. So, thank you!

The one problem I'm having is that I work with hex color codes a lot (#0f0f0f, #ebebeb, etc). Since numbers are considered the start of a new word, codes like #0f0f0f quickly get in the way. I understand that numbers should be separate words in some languages, but these hex codes are where I most often encounter them.

I would like to request an option to change whether numbers are considered words.

Or maybe include these codes along with the other hex literals (0x00ffFF), since they are essentially the same thing.

Unsure how to customize

Hi, I'm sorry but I didn't quite follow how to setup my own keys.

Let's say I want to preserve the default behavior of 'w', 'W', 'b', 'B', 'e', 'E', 'ge' and 'gE'. And I want to set up new motions <M-w>, <M-e>, <M-b> to perform camel-case etc. traversal. What do I need to do?

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.