Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Custom function/map to translate selected text to link target/url #13

Closed
lervag opened this issue Sep 24, 2018 · 2 comments
Closed

Comments

@lervag
Copy link
Owner

lervag commented Sep 24, 2018

This was suggested by @BonaBeavis in #12.

The idea is to allow a custom map or function that is applied in order to transform the selected text when creating a new link.

Presently, if one selects Some text and creates a link with the <cr> visual mode mapping, the link becomes [[Some text]], i.e. the same text is used for the link target. The proposal is to allow a user to customize this, e.g. with:

let g:wiki_link_target_map = "MyFunction"

function MyFunction(text) abort
  return substitute(tolower(a:text), '\s\+', '-', 'g')
endfunction

With this configuration, the result of pressing <cr> on Some text would now be [[some-text|Some text]].

@lervag
Copy link
Owner Author

lervag commented Sep 24, 2018

Relevant parts of the code include wiki#link#toggle, wiki#link#toggle_visual, and wiki#link#toggle_operator, as well as s:parser_word() in the same file.

@lervag
Copy link
Owner Author

lervag commented Feb 28, 2019

@BonaBeavis Not sure if you still care about this plugin, but if you do then I have finally added the text to url map feature. I would be happy to hear if you think it works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant