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 6966041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:08:23+00:00 2026-05-27T16:08:23+00:00

In some of my programming, off late, I have often had to manually enter

  • 0

In some of my programming, off late, I have often had to manually enter in the values of a long std::vector. So for a vector of size 30, I have to keep typing

myvec[0]=1.0;
myvec[1]=4.6;
myvec[2]=6.7;
myvec[3]=7.8;
.
.
myvec[29]=87;

I use Emacs as a text editor. Is it possible in Emacs for me to somehow specify that say from lines 30 to 59 insert the lines

myvec[0]= ;
myvec[1]= ;
myvec[2]= ;
.
.
myvec[29]= ;  

The individual values of the vector will of course have to be manually entered, but it would save me a lot of typing or copy/pasting myvec[] again and again.

  • 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-05-27T16:08:24+00:00Added an answer on May 27, 2026 at 4:08 pm

    Keyboard Macros is
    the simpler way to do it.

    C-x(myvec[C-xC-kC-i]
    = ;
    RETC-x)

    • C-x( starts the macro definition
    • C-xC-kC-i
      inserts and increments the counter
    • C-x) ends the macro
      definition

    And then
    M-3M-9C-xe

    • M-3M-9 is a short cut for
      C-u39 and is used to send 39 as an
      argument
    • C-xe executes the last macro
      recorded

    Thus the combination of both executes the macro 39 times.

    You can also look in the manual to see how you can save them and edit them.

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

Sidebar

Related Questions

I'm programming some C code using gcc -std=C89 switch on a Linux box. This
I am doing some C programming for school and I have found myself reusing
I am currently doing some network programming and had a couple questions concerning timeouts.
I have been doing some x86 programming in Windows with NASM and I have
I'm new to funcctional programming and have some questions regarding coding style and debugging.
Some popular programming languages use month numbering which is off by 1 -- JavaScript
I have recently started programming for the iOS Platform but now I need some
When programming and looking at all different apps I have realized that some apps
First off, I have only really used Objective-c methods in my programming. I decided
I' ve been doing some programming lately and faced an issue which i found

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.