How to insert enough spaces to align text to column number using Vim?Is there anyway to have vim not count...

A Missing Symbol for This Logo

Globe trotting Grandpa. Where is he going next?

Why avoid shared user accounts?

Is "the fire consumed everything on its way" correct?

How to access internet and run apt-get through a middle server?

Most demanding German Newspapers

Why zero tolerance on nudity in space?

Do authors have to be politically correct in article-writing?

What game did these black and yellow dice come from?

Cat is tipping over bed-side lamps during the night

Which communication protocol is used in AdLib sound card?

What happens when the wearer of a Shield of Missile Attraction is behind total cover?

Is there any other language containing the sound of the "evanescent l" in Venetian?

How would an AI self awareness kill switch work?

TikZ graph edges not drawn nicely

Bash script to truncate subject line of incoming email

Does Skippy chunky peanut butter contain trans fat?

Square Root Distance from Integers

Potential client has a problematic employee I can't work with

Play Zip, Zap, Zop

What is the wife of a henpecked husband called?

Why would space fleets be aligned?

Has Britain negotiated with any other countries outside the EU in preparation for the exit?

How can the probability of a fumble decrease linearly with more dice?



How to insert enough spaces to align text to column number using Vim?


Is there anyway to have vim not count special characters as words?Why is Vim misbehaving when I try to do a column mode insert?How can I check whether Vim has the -p (tabs) option or not?Vim text messed up on remote serverVim colors debuggingPossible for vim marks to point to the character to which they are originally set instead of the character's original line/column location?Unicode keyboard on Mac OSX mess VIM editor badlyVim: changing tabs to spacesHow to extract specific lines from large .txt file based on search patternCan't select text in terminal after upgrading to VIM 8 on Debian 9 Stretch













4















  COMP_ID=`      echo $SRC | sed -e 's/.*COMP_ID=//'  -e 's/:.*$//'`
SRC_TYP=` echo $SRC | sed -e 's/.*SRC_TYP=//' -e 's/:.*$//'`
DOC_TYP=` echo $SRC | sed -e 's/.*DOC_TYP=//' -e 's/:.*$//'`
SRC_ID=` echo $SRC | sed -e 's/.*SRC_ID=//' -e 's/:.*$//'`
ACC=` echo $SRC | sed -e 's/.*ACC=//' -e 's/:.*$//'`
PASS=` echo $SRC | sed -e 's/.*PASS=//' -e 's/:.*$//'`
POP=` echo $SRC | sed -e 's/.*POP=//' -e 's/:.*$//'`
REMOTE_HOST=` echo $SRC | sed -e 's/.*REMOTE_HOST=//' -e 's/:.*$//'`
REMOTE_PATH=` echo $SRC | sed -e 's/.*REMOTE_PATH=//' -e 's/:.*$//'`
ARCHIVE_PATH=` echo $SRC | sed -e 's/.*ARCHIVE_PATH=//' -e 's/:.*$//'`


Using vim (or vi) I want to align the sections with -e 's/:.*$//' to the same column number. What's the easiest and fastest way to do this? (ignore the ugly echo ..| sed .. bits for now)










share|improve this question

























  • Did you consider using a plugin like Align or Tabular?

    – romainl
    Jun 20 '14 at 6:44
















4















  COMP_ID=`      echo $SRC | sed -e 's/.*COMP_ID=//'  -e 's/:.*$//'`
SRC_TYP=` echo $SRC | sed -e 's/.*SRC_TYP=//' -e 's/:.*$//'`
DOC_TYP=` echo $SRC | sed -e 's/.*DOC_TYP=//' -e 's/:.*$//'`
SRC_ID=` echo $SRC | sed -e 's/.*SRC_ID=//' -e 's/:.*$//'`
ACC=` echo $SRC | sed -e 's/.*ACC=//' -e 's/:.*$//'`
PASS=` echo $SRC | sed -e 's/.*PASS=//' -e 's/:.*$//'`
POP=` echo $SRC | sed -e 's/.*POP=//' -e 's/:.*$//'`
REMOTE_HOST=` echo $SRC | sed -e 's/.*REMOTE_HOST=//' -e 's/:.*$//'`
REMOTE_PATH=` echo $SRC | sed -e 's/.*REMOTE_PATH=//' -e 's/:.*$//'`
ARCHIVE_PATH=` echo $SRC | sed -e 's/.*ARCHIVE_PATH=//' -e 's/:.*$//'`


Using vim (or vi) I want to align the sections with -e 's/:.*$//' to the same column number. What's the easiest and fastest way to do this? (ignore the ugly echo ..| sed .. bits for now)










share|improve this question

























  • Did you consider using a plugin like Align or Tabular?

    – romainl
    Jun 20 '14 at 6:44














4












4








4


1






  COMP_ID=`      echo $SRC | sed -e 's/.*COMP_ID=//'  -e 's/:.*$//'`
SRC_TYP=` echo $SRC | sed -e 's/.*SRC_TYP=//' -e 's/:.*$//'`
DOC_TYP=` echo $SRC | sed -e 's/.*DOC_TYP=//' -e 's/:.*$//'`
SRC_ID=` echo $SRC | sed -e 's/.*SRC_ID=//' -e 's/:.*$//'`
ACC=` echo $SRC | sed -e 's/.*ACC=//' -e 's/:.*$//'`
PASS=` echo $SRC | sed -e 's/.*PASS=//' -e 's/:.*$//'`
POP=` echo $SRC | sed -e 's/.*POP=//' -e 's/:.*$//'`
REMOTE_HOST=` echo $SRC | sed -e 's/.*REMOTE_HOST=//' -e 's/:.*$//'`
REMOTE_PATH=` echo $SRC | sed -e 's/.*REMOTE_PATH=//' -e 's/:.*$//'`
ARCHIVE_PATH=` echo $SRC | sed -e 's/.*ARCHIVE_PATH=//' -e 's/:.*$//'`


Using vim (or vi) I want to align the sections with -e 's/:.*$//' to the same column number. What's the easiest and fastest way to do this? (ignore the ugly echo ..| sed .. bits for now)










share|improve this question
















  COMP_ID=`      echo $SRC | sed -e 's/.*COMP_ID=//'  -e 's/:.*$//'`
SRC_TYP=` echo $SRC | sed -e 's/.*SRC_TYP=//' -e 's/:.*$//'`
DOC_TYP=` echo $SRC | sed -e 's/.*DOC_TYP=//' -e 's/:.*$//'`
SRC_ID=` echo $SRC | sed -e 's/.*SRC_ID=//' -e 's/:.*$//'`
ACC=` echo $SRC | sed -e 's/.*ACC=//' -e 's/:.*$//'`
PASS=` echo $SRC | sed -e 's/.*PASS=//' -e 's/:.*$//'`
POP=` echo $SRC | sed -e 's/.*POP=//' -e 's/:.*$//'`
REMOTE_HOST=` echo $SRC | sed -e 's/.*REMOTE_HOST=//' -e 's/:.*$//'`
REMOTE_PATH=` echo $SRC | sed -e 's/.*REMOTE_PATH=//' -e 's/:.*$//'`
ARCHIVE_PATH=` echo $SRC | sed -e 's/.*ARCHIVE_PATH=//' -e 's/:.*$//'`


Using vim (or vi) I want to align the sections with -e 's/:.*$//' to the same column number. What's the easiest and fastest way to do this? (ignore the ugly echo ..| sed .. bits for now)







vim vi






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 17 mins ago









kenorb

11.2k1578116




11.2k1578116










asked Jun 20 '14 at 6:13









Felipe AlvarezFelipe Alvarez

1,12031832




1,12031832













  • Did you consider using a plugin like Align or Tabular?

    – romainl
    Jun 20 '14 at 6:44



















  • Did you consider using a plugin like Align or Tabular?

    – romainl
    Jun 20 '14 at 6:44

















Did you consider using a plugin like Align or Tabular?

– romainl
Jun 20 '14 at 6:44





Did you consider using a plugin like Align or Tabular?

– romainl
Jun 20 '14 at 6:44










2 Answers
2






active

oldest

votes


















3














For alignment, there are three well-known plugins:




  • the venerable Align - Help folks to align text, eqns, declarations, tables, etc

  • the modern tabular

  • the contender vim-easy-align


With the first, your problem can be solved via



:%Align -e





share|improve this answer
























  • Well done. thanks for the those tips. For history's sake, the first two failed to install or operate correctly for me. vim-easy-plugin was the ticket. Did exactly what I want. vip<enter>-<CTRL-/> -e <enter> did it for me. My version VIM - Vi IMproved 7.0 (2006 May 7, compiled Jun 12 2009 07:08:36)

    – Felipe Alvarez
    Jun 27 '14 at 6:05













  • Why are you using such an outdated Vim version?! By updating, you'll get many fixes and new features!

    – Ingo Karkat
    Jun 27 '14 at 6:12



















1














You can do it with no plug-in, like this:



:%s#(.*)zsze-e#=repeat(' ',58-strlen(submatch(1)))


Note: This assumes that -e is the last of line. But you can capture it otherwise if it is not suitable to your case.



Explanation:





  • %s#(.*) - captures the line before the -e.


  • zsze - starts and stops the match here.


  • -e# - just before the -e.

  • Using zs and ze here let us to add our spaces directly before -e (otherwise concatenation with .submatch(x) would have been possible).


  • =repeat(' ',58-strlen(submatch(1))) - replace this location with a variable number of spaces and where 58 is your aimed column.






share|improve this answer










New contributor




bzbzh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f771140%2fhow-to-insert-enough-spaces-to-align-text-to-column-number-using-vim%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    For alignment, there are three well-known plugins:




    • the venerable Align - Help folks to align text, eqns, declarations, tables, etc

    • the modern tabular

    • the contender vim-easy-align


    With the first, your problem can be solved via



    :%Align -e





    share|improve this answer
























    • Well done. thanks for the those tips. For history's sake, the first two failed to install or operate correctly for me. vim-easy-plugin was the ticket. Did exactly what I want. vip<enter>-<CTRL-/> -e <enter> did it for me. My version VIM - Vi IMproved 7.0 (2006 May 7, compiled Jun 12 2009 07:08:36)

      – Felipe Alvarez
      Jun 27 '14 at 6:05













    • Why are you using such an outdated Vim version?! By updating, you'll get many fixes and new features!

      – Ingo Karkat
      Jun 27 '14 at 6:12
















    3














    For alignment, there are three well-known plugins:




    • the venerable Align - Help folks to align text, eqns, declarations, tables, etc

    • the modern tabular

    • the contender vim-easy-align


    With the first, your problem can be solved via



    :%Align -e





    share|improve this answer
























    • Well done. thanks for the those tips. For history's sake, the first two failed to install or operate correctly for me. vim-easy-plugin was the ticket. Did exactly what I want. vip<enter>-<CTRL-/> -e <enter> did it for me. My version VIM - Vi IMproved 7.0 (2006 May 7, compiled Jun 12 2009 07:08:36)

      – Felipe Alvarez
      Jun 27 '14 at 6:05













    • Why are you using such an outdated Vim version?! By updating, you'll get many fixes and new features!

      – Ingo Karkat
      Jun 27 '14 at 6:12














    3












    3








    3







    For alignment, there are three well-known plugins:




    • the venerable Align - Help folks to align text, eqns, declarations, tables, etc

    • the modern tabular

    • the contender vim-easy-align


    With the first, your problem can be solved via



    :%Align -e





    share|improve this answer













    For alignment, there are three well-known plugins:




    • the venerable Align - Help folks to align text, eqns, declarations, tables, etc

    • the modern tabular

    • the contender vim-easy-align


    With the first, your problem can be solved via



    :%Align -e






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jun 20 '14 at 6:44









    Ingo KarkatIngo Karkat

    17.7k22544




    17.7k22544













    • Well done. thanks for the those tips. For history's sake, the first two failed to install or operate correctly for me. vim-easy-plugin was the ticket. Did exactly what I want. vip<enter>-<CTRL-/> -e <enter> did it for me. My version VIM - Vi IMproved 7.0 (2006 May 7, compiled Jun 12 2009 07:08:36)

      – Felipe Alvarez
      Jun 27 '14 at 6:05













    • Why are you using such an outdated Vim version?! By updating, you'll get many fixes and new features!

      – Ingo Karkat
      Jun 27 '14 at 6:12



















    • Well done. thanks for the those tips. For history's sake, the first two failed to install or operate correctly for me. vim-easy-plugin was the ticket. Did exactly what I want. vip<enter>-<CTRL-/> -e <enter> did it for me. My version VIM - Vi IMproved 7.0 (2006 May 7, compiled Jun 12 2009 07:08:36)

      – Felipe Alvarez
      Jun 27 '14 at 6:05













    • Why are you using such an outdated Vim version?! By updating, you'll get many fixes and new features!

      – Ingo Karkat
      Jun 27 '14 at 6:12

















    Well done. thanks for the those tips. For history's sake, the first two failed to install or operate correctly for me. vim-easy-plugin was the ticket. Did exactly what I want. vip<enter>-<CTRL-/> -e <enter> did it for me. My version VIM - Vi IMproved 7.0 (2006 May 7, compiled Jun 12 2009 07:08:36)

    – Felipe Alvarez
    Jun 27 '14 at 6:05







    Well done. thanks for the those tips. For history's sake, the first two failed to install or operate correctly for me. vim-easy-plugin was the ticket. Did exactly what I want. vip<enter>-<CTRL-/> -e <enter> did it for me. My version VIM - Vi IMproved 7.0 (2006 May 7, compiled Jun 12 2009 07:08:36)

    – Felipe Alvarez
    Jun 27 '14 at 6:05















    Why are you using such an outdated Vim version?! By updating, you'll get many fixes and new features!

    – Ingo Karkat
    Jun 27 '14 at 6:12





    Why are you using such an outdated Vim version?! By updating, you'll get many fixes and new features!

    – Ingo Karkat
    Jun 27 '14 at 6:12













    1














    You can do it with no plug-in, like this:



    :%s#(.*)zsze-e#=repeat(' ',58-strlen(submatch(1)))


    Note: This assumes that -e is the last of line. But you can capture it otherwise if it is not suitable to your case.



    Explanation:





    • %s#(.*) - captures the line before the -e.


    • zsze - starts and stops the match here.


    • -e# - just before the -e.

    • Using zs and ze here let us to add our spaces directly before -e (otherwise concatenation with .submatch(x) would have been possible).


    • =repeat(' ',58-strlen(submatch(1))) - replace this location with a variable number of spaces and where 58 is your aimed column.






    share|improve this answer










    New contributor




    bzbzh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.

























      1














      You can do it with no plug-in, like this:



      :%s#(.*)zsze-e#=repeat(' ',58-strlen(submatch(1)))


      Note: This assumes that -e is the last of line. But you can capture it otherwise if it is not suitable to your case.



      Explanation:





      • %s#(.*) - captures the line before the -e.


      • zsze - starts and stops the match here.


      • -e# - just before the -e.

      • Using zs and ze here let us to add our spaces directly before -e (otherwise concatenation with .submatch(x) would have been possible).


      • =repeat(' ',58-strlen(submatch(1))) - replace this location with a variable number of spaces and where 58 is your aimed column.






      share|improve this answer










      New contributor




      bzbzh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.























        1












        1








        1







        You can do it with no plug-in, like this:



        :%s#(.*)zsze-e#=repeat(' ',58-strlen(submatch(1)))


        Note: This assumes that -e is the last of line. But you can capture it otherwise if it is not suitable to your case.



        Explanation:





        • %s#(.*) - captures the line before the -e.


        • zsze - starts and stops the match here.


        • -e# - just before the -e.

        • Using zs and ze here let us to add our spaces directly before -e (otherwise concatenation with .submatch(x) would have been possible).


        • =repeat(' ',58-strlen(submatch(1))) - replace this location with a variable number of spaces and where 58 is your aimed column.






        share|improve this answer










        New contributor




        bzbzh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.










        You can do it with no plug-in, like this:



        :%s#(.*)zsze-e#=repeat(' ',58-strlen(submatch(1)))


        Note: This assumes that -e is the last of line. But you can capture it otherwise if it is not suitable to your case.



        Explanation:





        • %s#(.*) - captures the line before the -e.


        • zsze - starts and stops the match here.


        • -e# - just before the -e.

        • Using zs and ze here let us to add our spaces directly before -e (otherwise concatenation with .submatch(x) would have been possible).


        • =repeat(' ',58-strlen(submatch(1))) - replace this location with a variable number of spaces and where 58 is your aimed column.







        share|improve this answer










        New contributor




        bzbzh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer








        edited 18 mins ago









        kenorb

        11.2k1578116




        11.2k1578116






        New contributor




        bzbzh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered 1 hour ago









        bzbzhbzbzh

        112




        112




        New contributor




        bzbzh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        bzbzh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        bzbzh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f771140%2fhow-to-insert-enough-spaces-to-align-text-to-column-number-using-vim%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Cannot install PyQt5 The Next CEO of Stack OverflowCannot install tcpreplay 3.4.4cannot...

            Kapp-Putsch Acontecimentos | Outros artigos | Menu de navegação

            Why did early computer designers eschew integers? The Next CEO of Stack OverflowWhat register...