Skip to content

Support for cword in custom function? #723

Answered by lippfi
marcin-krajewski asked this question in Q&A
Discussion options

You must be logged in to vote

Hello!

I attempted to create the same mapping a year ago, and this is what I had in my .ideavimrc (it's a bit rough, but you can grasp the general idea). However, a lot has changed over the year, and there might now be additional functions that could facilitate a smoother implementation (e.g., utilizing dictionary-related functions instead of lists).

function! Invert(calledFromVisual)
  let antonyms = ['true', 'false', 'after', 'before', 'start', 'end', 'left', 'right', 'first', 'last',
                 \'True', 'False', 'After', 'Before', 'Start', 'End', 'Left', 'Right', 'First', 'Last']

  if a:calledFromVisual
    normal gv"wy
  else
    normal "wyiw
  endif
  let wordUnderCaret = @w

…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@marcin-krajewski
Comment options

Answer selected by lippfi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants