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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:44:37+00:00 2026-06-09T13:44:37+00:00

I was trying to learn some new neat shortcuts in vim and I discovered

  • 0

I was trying to learn some new neat shortcuts in vim and I discovered g_. According to
http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/

$  → go to the end of line
g_ → go to the last non-blank character of line

When would I use g_ instead of $?

  • 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-09T13:44:39+00:00Added an answer on June 9, 2026 at 1:44 pm

    I think the most important difference is simply stated in the help files:

    :h $
    In Visual mode the cursor goes to just after the last character in the line.
    

    So if you do v$d it deletes including “after the last character” which is the newline so it will bring the line below it up to the current one. But if you do vg_d it will keep the newline.

    I actually didn’t know about g_, seems useful.

    Edit Since this answer gets upvotes, I have since used g_ (and its reverse, _) to make a mapping that yanks / deletes the current line excluding leading/trailing whitespace and excluding linebreaks:

    " delete/yank line, but only whitespace-trimmed version
    nnoremap <Leader>dd _yg_"_dd
    nnoremap <Leader>yy _yg_
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm relatively new to TDD, and still trying to learn to apply some of
I'm new to Android and trying to learn how to pass some variables from
I'm new to YQL, and just trying to learn how to do some fairly
I'm trying to learn the ropes of some new MySQL syntax and am having
I'm new to Javascript and trying to learn some basics. Can you please check
So I'm new to C++ and am trying to learn some things. As such
I am new to computer programming, and trying to learn some possibilities to track
Building a new website at work and I'm trying to learn some TDD so
new to jquery here but I'm trying to learn some different stuff that's been
I am new to PHP and trying to learn some so sorry if this

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.