Search code examples
vimediting

Vim advanced substitution


I've done a lot of complex edits and also used sed a lot in the past, but this is something that I can't quite figure out how to do. I know how to use beginning and end of line (^$), and wildcards (.*$), and even throwing in CRs, but this is columnar. I have the following lines:

!********************************************************************************
!                                                                               *
! Processing Overview:                                                          *
!                                                                               *
!     begin-setup                                                               *
!     begin-heading        *
!     begin-footing        *
!     begin-report        *
!          Strd-begin-Program       *
!          STRD-Print-Lis       *
!          Prompt-Parameters                                                    *
!          Feedback-Value-Update                                                *

I need to move the asterisk to column 81 on all lines for uniformity and readability. Anyone know how to do that? TIA, David


Solution

  • One option would be something like

    %norm $x80|p
    

    Breakdown

    %             operate on the entire buffer
    norm          following normal command
    $             go to end of the line
    x             delete the character
    80|           goto column 80
    p             paste
    

    Note that virtual edit needs to be set. I have following entry in my _vimrc

     set ve=all