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

  • SEARCH
  • Home
  • 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 262401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:30:45+00:00 2026-05-11T22:30:45+00:00

I have found the following command in AWK useful in Vim :'<,’>!awk ‘{ print

  • 0

I have found the following command in AWK useful in Vim

:'<,'>!awk '{ print $2 }'

Python may also be useful in Vim.
However, I have not found an useful command in Python for Vim’s visual mode.

Which Python commands do you use in Vim?

  • 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-11T22:30:45+00:00Added an answer on May 11, 2026 at 10:30 pm

    It’s hard to make useful one-liner filters in Python. You need to import sys to get stdin, and already you’re starting to push it. This isn’t to say anything bad about Python. My feeling is that Python is optimized for multi-line scripts, while the languages that do well at one-liners (awk, sed, bash, I could name others but would probably be flamed…) tend work less well (IMHO) when writing scripts of any significant complexity.

    I do really like Python for writing multi-line scripts that I can invoke from Vim. For example, I’ve got one Python script that will, when given a signature for a Java constructor, like this:

    Foo(String name, int size) {
    

    will emit a lot of the boilerplate that goes into creating a value class:

    private final String name;
    private final int size;
    
    public String getName() {
      return name;
    }
    
    public int getSize() {
      return size;
    }
    
    @Override
    public boolean equals(Object that) {
      return this == that
          || (that instanceof Foo && equals((Foo) that));
    }
    
    public boolean equals(Foo that) {
      return Objects.equal(getName(), that.getName())
          && this.getSize() == that.getSize();
    }
    
    @Override
    public int hashCode() {
      return Objects.hashCode(
          getName(),
          getSize());
    }
    
    Foo(String name, int size) {
      this.name = Preconditions.checkNotNull(name);
      this.size = size;
    

    I use this from Vim by highlighting the signature and then typing !jhelper.py.

    I also used to use Python scripts I’d written to reverse characters in lines and to reverse the lines of a file before I found out about rev and tac.

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

Sidebar

Ask A Question

Stats

  • Questions 165k
  • Answers 165k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There are a couple of variants of a rename command,… May 12, 2026 at 12:33 pm
  • Editorial Team
    Editorial Team added an answer There is currently no way to build CLS-compliant assemblies from… May 12, 2026 at 12:33 pm
  • Editorial Team
    Editorial Team added an answer You might want to look at Google Protocol Buffers or… May 12, 2026 at 12:33 pm

Related Questions

I have found the following command in AWK useful in Vim :'<,'>!awk '{ print
edit #2: Question solved halfways. Look below As a follow-up question, does anyone know
I have not found a reason why Mac's find does not have the option
I have not yet found an easy solution to copy your file to a
I have a project to do in school which is baffeling me... I am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.