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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:16:31+00:00 2026-05-12T18:16:31+00:00

Okay, suppose we have a line of text: [s]tackoverflow rocks where the brackets show

  • 0

Okay, suppose we have a line of text:

[s]tackoverflow rocks

where the brackets show the location of the cursor, in normal mode. After pressing tr, you get:

stackov[e]rflow rocks

Now for the fun part. What happens if you push ; to repeat the command? Nothing! Vim finds the next ‘r’ (immediately to the right of the cursor) and positions itself just left of that (where it already was).

I would prefer that ; advance the cursor to this position:

stackoverflow[ ]rocks

This can be achieved by using l to move right one character before pressing ;, but the extra step is irritating. There is a similar issue with T, but not with f and F. Is there some way to make ; behave the way I want with t and T?

  • 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-12T18:16:31+00:00Added an answer on May 12, 2026 at 6:16 pm

    Maybe it’s not the answer you are looking for but I could not resist writing a VIM script for this. I put it in my .vimrc and it works for me:

    map ; :call Semicolon()<CR>
    function Semicolon()
       let s:pos1 = getpos(".")
       normal! ;
       let s:pos2 = getpos(".")
       if s:pos1 == s:pos2
          normal! 2;
       endif
    endfunction 
    

    The basic idea is that ; will not move to the next match, but 2; will (if there is a match). The script supports ; after any of tTfF. The easiest way to implement the , command is to write a similar function for that.

    EDIT
    Changed the script after Luc’s excellent suggestion

    EDIT2

    OK, these things are always more difficult than I originally think. The current mapping has the following problems:

    1. Suppose you did a search like tr above. Now what should d; or c; do? As far as I’m concerned they should delete or change up until the first r not the second. This can be solved by only doing the mapping for normal and visual mode, not operator pending mode.
    2. The current mapping does not work in visual mode. i.e., if you type v;;;; after the first ; the editor is no longer in visual mode (because of the :call). This can be solved by calling the function using @= instead of :call.

    So now I end up with the following in my .vimrc (I also made one function for , and ;):

    " Remap ; and , commands so they also work after t and T
    " Only do the remapping for normal and visual mode, not operator pending
    " Use @= instead of :call to prevent leaving visual mode
    nmap ; @=FixCommaAndSemicolon(";")<CR>
    nmap , @=FixCommaAndSemicolon(",")<CR>
    vmap ; @=FixCommaAndSemicolon(";")<CR>
    vmap , @=FixCommaAndSemicolon(",")<CR>
    function FixCommaAndSemicolon(command)
       let s:pos1 = getpos(".")
       execute "normal! " . a:command
       let s:pos2 = getpos(".")
       if s:pos1 == s:pos2
          execute "normal! 2" . a:command
       endif
       return ""
    endfunction 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay so say I have a fixed width TextView and the text inside it
Okay, suppose I have a 3D matrix A and another 3D matrix Inds. What
Okay, suppose I have a bunch of variables, one of them declared volatile: int
Okay I have this RewriteRule which is supposed to redirect any request for the
Okay, what have I done wrong here? I'm trying to .POST data from a
Okay, I feel like I should be able to do this, but I have
Suppose I have a table with a column name varchar(20) , and I store
Okay - yes, this is homework, but it isn't mine. I have a friend
Okay, here is the problem. I have an unordered list with a bunch of
Suppose I have some code, struct NodeVector { vector<bool_node*> *vec; }; I want 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.