Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8280795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:48:33+00:00 2026-06-08T09:48:33+00:00

Is there some sort of Vim plugin that would allow me to do something

  • 0

Is there some sort of Vim plugin that would allow me to do something like this, given the code:

function something (arbitraryObject) {
  arbitraryObject.something = doesNotMatter;
}

Then let’s say I just select the word arbitraryObject in the function body, I’d like an easy way to write a macro that, given a short key combination or command-mode command, could give me something like:

function something (arbitraryObject) {
  arbitraryObject.something = doesNotMatter;
  console.log(arbitraryObject);
}

or…

function something (arbitraryObject) {
  arbitraryObject.something = doesNotMatter;
  window.arbitraryObject = arbitraryObject;
}

Note that I’m not asking what this macro would actually look like, I’m curious if there are built-in tools or plugins that make the creation of things like this particularly easy.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T09:48:35+00:00Added an answer on June 8, 2026 at 9:48 am

    I know that you aren’t asking for the specific macro, but it’s easiest to learn these types of things by example. The first one (console.log) can be achieved through this mapping:

    :vmap <leader>il y<esc>oconsole.log(<c-r>");<esc>
    

    Likewise, the second one could look like this:

    :vmap <leader>iw y<esc>owindow.<c-r>" = <c-r>";<esc>
    

    Can you spot the similarities? <leader>il means that the command binds to the leader key (usually ,) followed by i followed by l. You can check what the following commands mean by using :help [key] in vim, but the mappings basically yank (copy) the selected text, enters a new line (Esc, o) and then appends some text followed by Ctrl+r and ", which inserts the yanked text.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If there is some sort of debugging API that would allow someone to write
Is there some sort of on render function in jQuery. I'd like this function
Is is there some sort of library that would allow me to convert a
Is there some sort of Javascript or webGL framework that would make creating a
This is a 2 part question. 1) Is there some sort of program that
Is there some sort of HTML designer (WYSIWYG) available that allows me to draw
So is there some sort of built in checking in Dday iCalendar that checks
... or how does zmq deal with clients that disconnect? Is there some sort
Is there a way to run some sort of code analysis to find code
I have a function in vim that is calling update and I'd like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.