Indent several lines with VIM? The 2019 Stack Overflow Developer Survey Results Are InHow to yank a particular line without moving the cursor in vim?Auto indent / format code for Vim?VIM - how to minimize tabindent on hilighted textIndent the middle of multiple linesVim gg=G (reindent whole file) without losing current positionvim how to keep cursor position while copying textWrap all lines with character sequence in vimVim cursor highlights wrong positionvim: Match WORD in current block with balanced bracketsIn vim, how to detach/open an exist window to a new tab?
Is "plugging out" electronic devices an American expression?
When should I buy a clipper card after flying to OAK?
If a Druid sees an animal’s corpse, can they Wild Shape into that animal?
Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?
Protecting Dualbooting Windows from dangerous code (like rm -rf)
A poker game description that does not feel gimmicky
Delete all lines which don't have n characters before delimiter
How technical should a Scrum Master be to effectively remove impediments?
How to manage monthly salary
How are circuits which use complex ICs normally simulated?
What do hard-Brexiteers want with respect to the Irish border?
Do these rules for Critical Successes and Critical Failures seem fair?
Are spiders unable to hurt humans, especially very small spiders?
For what reasons would an animal species NOT cross a *horizontal* land bridge?
Button changing it's text & action. Good or terrible?
What are the motivations for publishing new editions of an existing textbook, beyond new discoveries in a field?
What does Linus Torvalds mean when he says that Git "never ever" tracks a file?
Right tool to dig six foot holes?
What could be the right powersource for 15 seconds lifespan disposable giant chainsaw?
Why hard-Brexiteers don't insist on a hard border to prevent illegal immigration after Brexit?
How come people say “Would of”?
Shouldn't "much" here be used instead of "more"?
FPGA - DIY Programming
Did Section 31 appear in Star Trek: The Next Generation?
Indent several lines with VIM?
The 2019 Stack Overflow Developer Survey Results Are InHow to yank a particular line without moving the cursor in vim?Auto indent / format code for Vim?VIM - how to minimize tabindent on hilighted textIndent the middle of multiple linesVim gg=G (reindent whole file) without losing current positionvim how to keep cursor position while copying textWrap all lines with character sequence in vimVim cursor highlights wrong positionvim: Match WORD in current block with balanced bracketsIn vim, how to detach/open an exist window to a new tab?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
For example, I'm editing this code:
<html>
<body>
<script>
var a = 10;
a += 100;
</script>
</body>
</html>
now I need to indent the script line:
<html>
<body>
<script>
var a = 10;
a += 100;
</script>
</body>
</html>
How could I do this without moving cursor to the begin of each line and press Tab?
vim vi
add a comment |
For example, I'm editing this code:
<html>
<body>
<script>
var a = 10;
a += 100;
</script>
</body>
</html>
now I need to indent the script line:
<html>
<body>
<script>
var a = 10;
a += 100;
</script>
</body>
</html>
How could I do this without moving cursor to the begin of each line and press Tab?
vim vi
In command mode:gg=G
– Prince John Wesley
Jul 19 '11 at 8:22
add a comment |
For example, I'm editing this code:
<html>
<body>
<script>
var a = 10;
a += 100;
</script>
</body>
</html>
now I need to indent the script line:
<html>
<body>
<script>
var a = 10;
a += 100;
</script>
</body>
</html>
How could I do this without moving cursor to the begin of each line and press Tab?
vim vi
For example, I'm editing this code:
<html>
<body>
<script>
var a = 10;
a += 100;
</script>
</body>
</html>
now I need to indent the script line:
<html>
<body>
<script>
var a = 10;
a += 100;
</script>
</body>
</html>
How could I do this without moving cursor to the begin of each line and press Tab?
vim vi
vim vi
edited Apr 7 at 15:32
Saca
1034
1034
asked Jul 19 '11 at 8:13
wong2wong2
848398
848398
In command mode:gg=G
– Prince John Wesley
Jul 19 '11 at 8:22
add a comment |
In command mode:gg=G
– Prince John Wesley
Jul 19 '11 at 8:22
In command mode:
gg=G
– Prince John Wesley
Jul 19 '11 at 8:22
In command mode:
gg=G
– Prince John Wesley
Jul 19 '11 at 8:22
add a comment |
5 Answers
5
active
oldest
votes
Press V
to switch to VISUAL LINE mode and highlight the lines you want to indent by pressing j
. Then press >
to indent them. So the complete command would be Vjjj>
.
Alternatively, put your cursor on the <script>
tag and use 4>>
to indent four lines.
1
Also, when changing multiple indent levels, . is extremely useful (it will move the same 'block' wether with visual, marks or a [count] like the above 4>>).
– Pif
Jan 17 '12 at 11:18
Also, if your syntax file can do tag matching, you can have your cursor on the word "script", and press v for visual mode, % to go to matching tag, and > to indent or = to auto indent based on syntax, so the total command would be v%> or v%=
– ben
Feb 1 '13 at 20:42
This works with character-wise visual mode too (lowercase v), which is a bit easier to type. So vjjj>
– James Scriven
Jan 3 '16 at 0:59
add a comment |
To supplement the above answer, take a look here.
https://stackoverflow.com/questions/235839/how-do-i-indent-multiple-lines-quickly-in-vi
There are more than one way to do this, and I can't hope to compete with documentation already provided there.
My personal favorite is ==
to auto-indent. 5==
to auto-indent 5 lines.
add a comment |
To indent the all the lines below the current line
=G
So, to indent entire file, go to the beginning of the file (gg
) and then indent all the lines below the current line (=G
)
gg=G
To indent the current line
==
So, to indent n
lines below the current line
n==
For example, to indent 4 lines below the current line
4==
These are the simplest commands to indent multiple lines.
add a comment |
If it was me, I would notice that there are 4 lines to indent, position onto the top line and then type >4>
. If there were too many lines to count, I would position onto the top line and type mk
to make a mark named k, then position onto the bottom line (which might be several screenfuls away), and type >'k
add a comment |
Here is a nice approach, if you are trying to indent over a great number of lines:
:/<script>/,/</script>/ >>
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2funix.stackexchange.com%2fquestions%2f16939%2findent-several-lines-with-vim%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
Press V
to switch to VISUAL LINE mode and highlight the lines you want to indent by pressing j
. Then press >
to indent them. So the complete command would be Vjjj>
.
Alternatively, put your cursor on the <script>
tag and use 4>>
to indent four lines.
1
Also, when changing multiple indent levels, . is extremely useful (it will move the same 'block' wether with visual, marks or a [count] like the above 4>>).
– Pif
Jan 17 '12 at 11:18
Also, if your syntax file can do tag matching, you can have your cursor on the word "script", and press v for visual mode, % to go to matching tag, and > to indent or = to auto indent based on syntax, so the total command would be v%> or v%=
– ben
Feb 1 '13 at 20:42
This works with character-wise visual mode too (lowercase v), which is a bit easier to type. So vjjj>
– James Scriven
Jan 3 '16 at 0:59
add a comment |
Press V
to switch to VISUAL LINE mode and highlight the lines you want to indent by pressing j
. Then press >
to indent them. So the complete command would be Vjjj>
.
Alternatively, put your cursor on the <script>
tag and use 4>>
to indent four lines.
1
Also, when changing multiple indent levels, . is extremely useful (it will move the same 'block' wether with visual, marks or a [count] like the above 4>>).
– Pif
Jan 17 '12 at 11:18
Also, if your syntax file can do tag matching, you can have your cursor on the word "script", and press v for visual mode, % to go to matching tag, and > to indent or = to auto indent based on syntax, so the total command would be v%> or v%=
– ben
Feb 1 '13 at 20:42
This works with character-wise visual mode too (lowercase v), which is a bit easier to type. So vjjj>
– James Scriven
Jan 3 '16 at 0:59
add a comment |
Press V
to switch to VISUAL LINE mode and highlight the lines you want to indent by pressing j
. Then press >
to indent them. So the complete command would be Vjjj>
.
Alternatively, put your cursor on the <script>
tag and use 4>>
to indent four lines.
Press V
to switch to VISUAL LINE mode and highlight the lines you want to indent by pressing j
. Then press >
to indent them. So the complete command would be Vjjj>
.
Alternatively, put your cursor on the <script>
tag and use 4>>
to indent four lines.
answered Jul 19 '11 at 8:30
dogbanedogbane
14.8k106458
14.8k106458
1
Also, when changing multiple indent levels, . is extremely useful (it will move the same 'block' wether with visual, marks or a [count] like the above 4>>).
– Pif
Jan 17 '12 at 11:18
Also, if your syntax file can do tag matching, you can have your cursor on the word "script", and press v for visual mode, % to go to matching tag, and > to indent or = to auto indent based on syntax, so the total command would be v%> or v%=
– ben
Feb 1 '13 at 20:42
This works with character-wise visual mode too (lowercase v), which is a bit easier to type. So vjjj>
– James Scriven
Jan 3 '16 at 0:59
add a comment |
1
Also, when changing multiple indent levels, . is extremely useful (it will move the same 'block' wether with visual, marks or a [count] like the above 4>>).
– Pif
Jan 17 '12 at 11:18
Also, if your syntax file can do tag matching, you can have your cursor on the word "script", and press v for visual mode, % to go to matching tag, and > to indent or = to auto indent based on syntax, so the total command would be v%> or v%=
– ben
Feb 1 '13 at 20:42
This works with character-wise visual mode too (lowercase v), which is a bit easier to type. So vjjj>
– James Scriven
Jan 3 '16 at 0:59
1
1
Also, when changing multiple indent levels, . is extremely useful (it will move the same 'block' wether with visual, marks or a [count] like the above 4>>).
– Pif
Jan 17 '12 at 11:18
Also, when changing multiple indent levels, . is extremely useful (it will move the same 'block' wether with visual, marks or a [count] like the above 4>>).
– Pif
Jan 17 '12 at 11:18
Also, if your syntax file can do tag matching, you can have your cursor on the word "script", and press v for visual mode, % to go to matching tag, and > to indent or = to auto indent based on syntax, so the total command would be v%> or v%=
– ben
Feb 1 '13 at 20:42
Also, if your syntax file can do tag matching, you can have your cursor on the word "script", and press v for visual mode, % to go to matching tag, and > to indent or = to auto indent based on syntax, so the total command would be v%> or v%=
– ben
Feb 1 '13 at 20:42
This works with character-wise visual mode too (lowercase v), which is a bit easier to type. So vjjj>
– James Scriven
Jan 3 '16 at 0:59
This works with character-wise visual mode too (lowercase v), which is a bit easier to type. So vjjj>
– James Scriven
Jan 3 '16 at 0:59
add a comment |
To supplement the above answer, take a look here.
https://stackoverflow.com/questions/235839/how-do-i-indent-multiple-lines-quickly-in-vi
There are more than one way to do this, and I can't hope to compete with documentation already provided there.
My personal favorite is ==
to auto-indent. 5==
to auto-indent 5 lines.
add a comment |
To supplement the above answer, take a look here.
https://stackoverflow.com/questions/235839/how-do-i-indent-multiple-lines-quickly-in-vi
There are more than one way to do this, and I can't hope to compete with documentation already provided there.
My personal favorite is ==
to auto-indent. 5==
to auto-indent 5 lines.
add a comment |
To supplement the above answer, take a look here.
https://stackoverflow.com/questions/235839/how-do-i-indent-multiple-lines-quickly-in-vi
There are more than one way to do this, and I can't hope to compete with documentation already provided there.
My personal favorite is ==
to auto-indent. 5==
to auto-indent 5 lines.
To supplement the above answer, take a look here.
https://stackoverflow.com/questions/235839/how-do-i-indent-multiple-lines-quickly-in-vi
There are more than one way to do this, and I can't hope to compete with documentation already provided there.
My personal favorite is ==
to auto-indent. 5==
to auto-indent 5 lines.
edited May 23 '17 at 12:39
Community♦
1
1
answered Jul 20 '11 at 15:16
user606723user606723
6811413
6811413
add a comment |
add a comment |
To indent the all the lines below the current line
=G
So, to indent entire file, go to the beginning of the file (gg
) and then indent all the lines below the current line (=G
)
gg=G
To indent the current line
==
So, to indent n
lines below the current line
n==
For example, to indent 4 lines below the current line
4==
These are the simplest commands to indent multiple lines.
add a comment |
To indent the all the lines below the current line
=G
So, to indent entire file, go to the beginning of the file (gg
) and then indent all the lines below the current line (=G
)
gg=G
To indent the current line
==
So, to indent n
lines below the current line
n==
For example, to indent 4 lines below the current line
4==
These are the simplest commands to indent multiple lines.
add a comment |
To indent the all the lines below the current line
=G
So, to indent entire file, go to the beginning of the file (gg
) and then indent all the lines below the current line (=G
)
gg=G
To indent the current line
==
So, to indent n
lines below the current line
n==
For example, to indent 4 lines below the current line
4==
These are the simplest commands to indent multiple lines.
To indent the all the lines below the current line
=G
So, to indent entire file, go to the beginning of the file (gg
) and then indent all the lines below the current line (=G
)
gg=G
To indent the current line
==
So, to indent n
lines below the current line
n==
For example, to indent 4 lines below the current line
4==
These are the simplest commands to indent multiple lines.
edited Aug 9 '14 at 7:38
answered Jul 31 '14 at 4:33
Sagar JainSagar Jain
20124
20124
add a comment |
add a comment |
If it was me, I would notice that there are 4 lines to indent, position onto the top line and then type >4>
. If there were too many lines to count, I would position onto the top line and type mk
to make a mark named k, then position onto the bottom line (which might be several screenfuls away), and type >'k
add a comment |
If it was me, I would notice that there are 4 lines to indent, position onto the top line and then type >4>
. If there were too many lines to count, I would position onto the top line and type mk
to make a mark named k, then position onto the bottom line (which might be several screenfuls away), and type >'k
add a comment |
If it was me, I would notice that there are 4 lines to indent, position onto the top line and then type >4>
. If there were too many lines to count, I would position onto the top line and type mk
to make a mark named k, then position onto the bottom line (which might be several screenfuls away), and type >'k
If it was me, I would notice that there are 4 lines to indent, position onto the top line and then type >4>
. If there were too many lines to count, I would position onto the top line and type mk
to make a mark named k, then position onto the bottom line (which might be several screenfuls away), and type >'k
answered Aug 11 '11 at 5:21
Michael DillonMichael Dillon
79737
79737
add a comment |
add a comment |
Here is a nice approach, if you are trying to indent over a great number of lines:
:/<script>/,/</script>/ >>
add a comment |
Here is a nice approach, if you are trying to indent over a great number of lines:
:/<script>/,/</script>/ >>
add a comment |
Here is a nice approach, if you are trying to indent over a great number of lines:
:/<script>/,/</script>/ >>
Here is a nice approach, if you are trying to indent over a great number of lines:
:/<script>/,/</script>/ >>
answered Aug 8 '11 at 5:46
bhinesleybhinesley
55847
55847
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- 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%2funix.stackexchange.com%2fquestions%2f16939%2findent-several-lines-with-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
In command mode:
gg=G
– Prince John Wesley
Jul 19 '11 at 8:22