Closed axvutt closed 1 year ago
Sorry but this is not going to change. The way how it currently works is that it essentially does a ciw
and then copies the word under the cursor. This is just not a very stable thing to do in VIM, but it works well enough if you don't do things like adding parentheses. So this is essentially not easily fixable, because it's hard to tell with VIM what exactly changed.
What were you even trying to do?
I see, no worries. Thanks for the answer.
What I wanted to do was to replace a variable name by a container name (list
, dict
, ...) whose items are accessed by indexing.
In the minimal example, we could start with:
x = np.linspace(0,1,10)
y = np.sqrt(x)
Then, for whatever reason, do something like this:
xlist = [None, None, None]
for n in range(3):
xlist[n] = np.linspace(0,1,10*n)
y = np.sqrt(xlist[n])
For something else I am currently working on, I tried a replacement like a
--> some_long_name[n]
, thinking of possibly change the index n
manually where relevant.
Probably a vim command like :%s/a/some_long_name\[n\]/gc
is in the end the best way to go.
I don't know about vim, but couldn't you use extmarks on neovim, to track the start/end of the word and know what was added?
Issue
Renaming a variable with
<leader>r
and typing a new name containing parentheses or brackets yields unexpected results.Steps to reproduce
Using
Vundle
as plugin manager.[^1] Using enclosed minimal configuration filemy.vimrc
[^1]: by the way, I could not updatejedi-vim
because of agit
error, see following log file vundle.logSample file
test.py
:vim test.py -u my.vimrc
x
, line 4<leader>r
xlist[1]
All occurrences ofx
are replaced bynp
in my case instead of the intended name. Similar problems occur if typing any variation ofblah(
,foo)
,bar[
... also if renaming with cursor placed onx
on line 5.Output of “:verbose JediDebugInfo”
Jedi-vim debug information
jedi-vim version
Global Python
Using Python version 3 to access Jedi.
/usr/bin/python3
3.8.10 (default, Mar 13 2023, 10:26:41), [GCC 9.4.0]
/usr/lib/python3.8/site.py
Jedi
/home/avoute/.vim/bundle/jedi-vim/pythonx/jedi/jedi/__init__.py
Jedi environment: <SameEnvironment: 3.8.10 in /usr>
/home/avoute/includes/python
/usr/lib/python38.zip
/usr/lib/python3.8
/usr/lib/python3.8/lib-dynload
/home/avoute/.local/lib/python3.8/site-packages
/usr/local/lib/python3.8/dist-packages
/usr/lib/python3/dist-packages
Known environments
Settings
:version
:messages
:scriptnames
``` 1: ~/tests/python/jedi-vim-bug/my.vimrc 2: /usr/share/vim/vim81/syntax/syntax.vim 3: /usr/share/vim/vim81/syntax/synload.vim 4: /usr/share/vim/vim81/syntax/syncolor.vim 5: /usr/share/vim/vim81/filetype.vim 6: /usr/share/vim/vim81/ftoff.vim 7: ~/.vim/bundle/Vundle.vim/autoload/vundle.vim 8: ~/.vim/bundle/Vundle.vim/autoload/vundle/config.vim 9: ~/.vim/bundle/vim-fugitive/ftdetect/fugitive.vim 10: ~/.vim/bundle/vimtex/ftdetect/cls.vim 11: ~/.vim/bundle/vimtex/ftdetect/tex.vim 12: ~/.vim/bundle/vimtex/ftdetect/tikz.vim 13: /usr/share/vim/vim81/ftplugin.vim 14: /usr/share/vim/vim81/indent.vim 15: ~/.vim/bundle/vim-surround/plugin/surround.vim 16: ~/.vim/bundle/vim-commentary/plugin/commentary.vim 17: ~/.vim/bundle/vim-fugitive/plugin/fugitive.vim 18: ~/.vim/bundle/nerdcommenter/plugin/nerdcommenter.vim 19: ~/.vim/bundle/nerdtree/plugin/NERD_tree.vim 20: ~/.vim/bundle/nerdtree/autoload/nerdtree.vim 21: ~/.vim/bundle/nerdtree/lib/nerdtree/path.vim 22: ~/.vim/bundle/nerdtree/lib/nerdtree/menu_controller.vim 23: ~/.vim/bundle/nerdtree/lib/nerdtree/menu_item.vim 24: ~/.vim/bundle/nerdtree/lib/nerdtree/key_map.vim 25: ~/.vim/bundle/nerdtree/lib/nerdtree/bookmark.vim 26: ~/.vim/bundle/nerdtree/lib/nerdtree/tree_file_node.vim 27: ~/.vim/bundle/nerdtree/lib/nerdtree/tree_dir_node.vim 28: ~/.vim/bundle/nerdtree/lib/nerdtree/opener.vim 29: ~/.vim/bundle/nerdtree/lib/nerdtree/creator.vim 30: ~/.vim/bundle/nerdtree/lib/nerdtree/flag_set.vim 31: ~/.vim/bundle/nerdtree/lib/nerdtree/nerdtree.vim 32: ~/.vim/bundle/nerdtree/lib/nerdtree/ui.vim 33: ~/.vim/bundle/nerdtree/lib/nerdtree/event.vim 34: ~/.vim/bundle/nerdtree/lib/nerdtree/notifier.vim 35: ~/.vim/bundle/nerdtree/autoload/nerdtree/ui_glue.vim 36: ~/.vim/bundle/nerdtree/nerdtree_plugin/exec_menuitem.vim 37: ~/.vim/bundle/nerdtree/nerdtree_plugin/fs_menu.vim 38: ~/.vim/bundle/nerdtree/nerdtree_plugin/vcs.vim 39: ~/.vim/bundle/jedi-vim/plugin/jedi.vim 40: ~/.vim/bundle/vimtex/plugin/vimtex.vim 41: ~/.vim/bundle/camelcasemotion/plugin/camelcasemotion.vim 42: ~/.vim/bundle/vim-signature/plugin/signature.vim 43: ~/.vim/bundle/vim-signature/autoload/signature/utils.vim 44: ~/.vim/bundle/fastfold/plugin/fastfold.vim 45: ~/.vim/bundle/simpylfold/plugin/SimpylFold.vim 46: /usr/share/vim/vim81/plugin/getscriptPlugin.vim 47: /usr/share/vim/vim81/plugin/gzip.vim 48: /usr/share/vim/vim81/plugin/logiPat.vim 49: /usr/share/vim/vim81/plugin/manpager.vim 50: /usr/share/vim/vim81/plugin/matchparen.vim 51: /usr/share/vim/vim81/plugin/netrwPlugin.vim 52: /usr/share/vim/vim81/plugin/rrhelper.vim 53: /usr/share/vim/vim81/plugin/spellfile.vim 54: /usr/share/vim/vim81/plugin/tarPlugin.vim 55: /usr/share/vim/vim81/plugin/tohtml.vim 56: /usr/share/vim/vim81/plugin/vimballPlugin.vim 57: /usr/share/vim/vim81/plugin/zipPlugin.vim 58: ~/.vim/bundle/vim-signature/after/plugin/signature.vim 59: /usr/share/vim/vim81/syntax/python.vim 60: ~/.vim/bundle/jedi-vim/after/syntax/python.vim 61: ~/.vim/bundle/jedi-vim/autoload/jedi.vim 62: ~/.vim/bundle/jedi-vim/ftplugin/python/jedi.vim 63: ~/.vim/bundle/simpylfold/ftplugin/python/SimpylFold.vim 64: ~/.vim/bundle/simpylfold/autoload/SimpylFold.vim 65: /usr/share/vim/vim81/ftplugin/python.vim 66: ~/.vim/bundle/jedi-vim/after/ftplugin/python/jedi.vim 67: /usr/share/vim/vim81/indent/python.vim 68: ~/.vim/bundle/vim-signature/autoload/signature/sign.vim 69: ~/.vim/bundle/vim-signature/autoload/signature/mark.vim ```