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
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
add a comment |
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
Did you consider using a plugin like Align or Tabular?
– romainl
Jun 20 '14 at 6:44
add a comment |
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
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
vim vi
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
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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
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 versionVIM - 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
add a comment |
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
zsandzehere 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 where58is your aimed column.
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.
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
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 versionVIM - 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
add a comment |
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
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 versionVIM - 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
add a comment |
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
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
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 versionVIM - 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
add a comment |
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 versionVIM - 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
add a comment |
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
zsandzehere 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 where58is your aimed column.
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.
add a comment |
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
zsandzehere 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 where58is your aimed column.
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.
add a comment |
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
zsandzehere 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 where58is your aimed column.
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
zsandzehere 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 where58is your aimed column.
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.
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.
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Did you consider using a plugin like Align or Tabular?
– romainl
Jun 20 '14 at 6:44