How do I save files edited with vim?
I can't save changes after editing
sudo vi /etc/network/interfaces
Text before editing:
auto lo
iface lo inet ...
Edited to:
auto eth0
iface eth0 inet dhcp
What key combination or sequence must I press to save this?
vim
add a comment |
I can't save changes after editing
sudo vi /etc/network/interfaces
Text before editing:
auto lo
iface lo inet ...
Edited to:
auto eth0
iface eth0 inet dhcp
What key combination or sequence must I press to save this?
vim
6
If you are not comfortable with editing files in terminal based editors likevi
orvim
, I would recommend using graphical based editor likegedit
to open them. Replacesudo vi
withgksu gedit
.
– Aditya
Feb 8 '13 at 15:15
5
Or usesudo nano
Its also command line but a lot more intuitive than vi.
– Warren Hill
Oct 19 '13 at 9:46
add a comment |
I can't save changes after editing
sudo vi /etc/network/interfaces
Text before editing:
auto lo
iface lo inet ...
Edited to:
auto eth0
iface eth0 inet dhcp
What key combination or sequence must I press to save this?
vim
I can't save changes after editing
sudo vi /etc/network/interfaces
Text before editing:
auto lo
iface lo inet ...
Edited to:
auto eth0
iface eth0 inet dhcp
What key combination or sequence must I press to save this?
vim
vim
edited Dec 19 '15 at 21:39
Braiam
52.2k20137222
52.2k20137222
asked Feb 8 '13 at 14:45
AndAnd
4361510
4361510
6
If you are not comfortable with editing files in terminal based editors likevi
orvim
, I would recommend using graphical based editor likegedit
to open them. Replacesudo vi
withgksu gedit
.
– Aditya
Feb 8 '13 at 15:15
5
Or usesudo nano
Its also command line but a lot more intuitive than vi.
– Warren Hill
Oct 19 '13 at 9:46
add a comment |
6
If you are not comfortable with editing files in terminal based editors likevi
orvim
, I would recommend using graphical based editor likegedit
to open them. Replacesudo vi
withgksu gedit
.
– Aditya
Feb 8 '13 at 15:15
5
Or usesudo nano
Its also command line but a lot more intuitive than vi.
– Warren Hill
Oct 19 '13 at 9:46
6
6
If you are not comfortable with editing files in terminal based editors like
vi
or vim
, I would recommend using graphical based editor like gedit
to open them. Replace sudo vi
with gksu gedit
.– Aditya
Feb 8 '13 at 15:15
If you are not comfortable with editing files in terminal based editors like
vi
or vim
, I would recommend using graphical based editor like gedit
to open them. Replace sudo vi
with gksu gedit
.– Aditya
Feb 8 '13 at 15:15
5
5
Or use
sudo nano
Its also command line but a lot more intuitive than vi.– Warren Hill
Oct 19 '13 at 9:46
Or use
sudo nano
Its also command line but a lot more intuitive than vi.– Warren Hill
Oct 19 '13 at 9:46
add a comment |
4 Answers
4
active
oldest
votes
You're probably in editing/insert mode. You need to type the following sequence :
Esc, to quit edit mode and fallback to command mode ;
:+w+q, start with a:
(colon) then pressw
and finallyq
to write and quit (or just:w
to write without quitting)- then press Enter to valid.
add a comment |
I usually press ESC and then hold Shift and press z twice. Just like you would like to type two capital Z letters in word editor :) That saves your document and closes your editor.
3
Oh man, shift and double z, what was the design logic behind that I wonder, "what's the least intuitive command we can create?", ubuntu sometimes pisses me off like mad
– S..
May 25 '14 at 11:10
4
@Sam, I just wanted to nitpick that vi has nothing in particular to do with ubuntu. Ubuntu was first released on 2004, while vi was created by Bill Joy around 1976, inspired by ed (dating back to 1971). This means that the shortcuts in vi predate those in almost any other still commonly used utility today. In a sort of coincidence, the first version of emacs, which has completely different weird shortcuts, was also released on 1976. Standardization efforts came much much later.
– yoniLavi
Nov 21 '14 at 2:00
Wow thanks for the info @yoniLavi , my points is still the same though, so hopefully standardization efforts keep advancing.. :)
– S..
Nov 21 '14 at 9:12
@Sam, vi keybindings are actually a lot more standard than you think; they're virtually ubiquitous. Practically any program can be made to emulate vi keybindings. Even the default Gmail keybindings are obviously (to a Vim user) based off of vi keybindings.
– Wildcard
Dec 21 '16 at 0:27
what about esc key does not work? Insert mode, just stopped.
– creator
Mar 10 '18 at 7:07
add a comment |
Check whether you have administrative (root) privileges to edit the file. use this command
whoami
If the result is not "root", then you are not supposed to edit the file.
To login as root user, use the below command
sudo su
or
su
Edit the file,
vi /etc/network/interfeces
After the changes, save the file using
- Press
Esc
to change the mode
:x
to save and quit the file
Thats all
add a comment |
this question was answered a long time ago, but in case it comes up in search engines again, this link is a nice vim cheatsheet that you might want to bookmark if you use vim a lot.
By the way, You can use :wq
to save and exit the file ( you should first press esc key to exit insert or replace mode and then press commands ) and use :q!
to exit without saving.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
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%2faskubuntu.com%2fquestions%2f252760%2fhow-do-i-save-files-edited-with-vim%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
You're probably in editing/insert mode. You need to type the following sequence :
Esc, to quit edit mode and fallback to command mode ;
:+w+q, start with a:
(colon) then pressw
and finallyq
to write and quit (or just:w
to write without quitting)- then press Enter to valid.
add a comment |
You're probably in editing/insert mode. You need to type the following sequence :
Esc, to quit edit mode and fallback to command mode ;
:+w+q, start with a:
(colon) then pressw
and finallyq
to write and quit (or just:w
to write without quitting)- then press Enter to valid.
add a comment |
You're probably in editing/insert mode. You need to type the following sequence :
Esc, to quit edit mode and fallback to command mode ;
:+w+q, start with a:
(colon) then pressw
and finallyq
to write and quit (or just:w
to write without quitting)- then press Enter to valid.
You're probably in editing/insert mode. You need to type the following sequence :
Esc, to quit edit mode and fallback to command mode ;
:+w+q, start with a:
(colon) then pressw
and finallyq
to write and quit (or just:w
to write without quitting)- then press Enter to valid.
edited Jan 26 at 18:57
Kulfy
4,84151743
4,84151743
answered Feb 8 '13 at 15:08
Édouard LopezÉdouard Lopez
3,56342236
3,56342236
add a comment |
add a comment |
I usually press ESC and then hold Shift and press z twice. Just like you would like to type two capital Z letters in word editor :) That saves your document and closes your editor.
3
Oh man, shift and double z, what was the design logic behind that I wonder, "what's the least intuitive command we can create?", ubuntu sometimes pisses me off like mad
– S..
May 25 '14 at 11:10
4
@Sam, I just wanted to nitpick that vi has nothing in particular to do with ubuntu. Ubuntu was first released on 2004, while vi was created by Bill Joy around 1976, inspired by ed (dating back to 1971). This means that the shortcuts in vi predate those in almost any other still commonly used utility today. In a sort of coincidence, the first version of emacs, which has completely different weird shortcuts, was also released on 1976. Standardization efforts came much much later.
– yoniLavi
Nov 21 '14 at 2:00
Wow thanks for the info @yoniLavi , my points is still the same though, so hopefully standardization efforts keep advancing.. :)
– S..
Nov 21 '14 at 9:12
@Sam, vi keybindings are actually a lot more standard than you think; they're virtually ubiquitous. Practically any program can be made to emulate vi keybindings. Even the default Gmail keybindings are obviously (to a Vim user) based off of vi keybindings.
– Wildcard
Dec 21 '16 at 0:27
what about esc key does not work? Insert mode, just stopped.
– creator
Mar 10 '18 at 7:07
add a comment |
I usually press ESC and then hold Shift and press z twice. Just like you would like to type two capital Z letters in word editor :) That saves your document and closes your editor.
3
Oh man, shift and double z, what was the design logic behind that I wonder, "what's the least intuitive command we can create?", ubuntu sometimes pisses me off like mad
– S..
May 25 '14 at 11:10
4
@Sam, I just wanted to nitpick that vi has nothing in particular to do with ubuntu. Ubuntu was first released on 2004, while vi was created by Bill Joy around 1976, inspired by ed (dating back to 1971). This means that the shortcuts in vi predate those in almost any other still commonly used utility today. In a sort of coincidence, the first version of emacs, which has completely different weird shortcuts, was also released on 1976. Standardization efforts came much much later.
– yoniLavi
Nov 21 '14 at 2:00
Wow thanks for the info @yoniLavi , my points is still the same though, so hopefully standardization efforts keep advancing.. :)
– S..
Nov 21 '14 at 9:12
@Sam, vi keybindings are actually a lot more standard than you think; they're virtually ubiquitous. Practically any program can be made to emulate vi keybindings. Even the default Gmail keybindings are obviously (to a Vim user) based off of vi keybindings.
– Wildcard
Dec 21 '16 at 0:27
what about esc key does not work? Insert mode, just stopped.
– creator
Mar 10 '18 at 7:07
add a comment |
I usually press ESC and then hold Shift and press z twice. Just like you would like to type two capital Z letters in word editor :) That saves your document and closes your editor.
I usually press ESC and then hold Shift and press z twice. Just like you would like to type two capital Z letters in word editor :) That saves your document and closes your editor.
edited Feb 8 '13 at 18:01
Kevin Bowen
14.6k155970
14.6k155970
answered Feb 8 '13 at 16:05
SephirothSephiroth
28113
28113
3
Oh man, shift and double z, what was the design logic behind that I wonder, "what's the least intuitive command we can create?", ubuntu sometimes pisses me off like mad
– S..
May 25 '14 at 11:10
4
@Sam, I just wanted to nitpick that vi has nothing in particular to do with ubuntu. Ubuntu was first released on 2004, while vi was created by Bill Joy around 1976, inspired by ed (dating back to 1971). This means that the shortcuts in vi predate those in almost any other still commonly used utility today. In a sort of coincidence, the first version of emacs, which has completely different weird shortcuts, was also released on 1976. Standardization efforts came much much later.
– yoniLavi
Nov 21 '14 at 2:00
Wow thanks for the info @yoniLavi , my points is still the same though, so hopefully standardization efforts keep advancing.. :)
– S..
Nov 21 '14 at 9:12
@Sam, vi keybindings are actually a lot more standard than you think; they're virtually ubiquitous. Practically any program can be made to emulate vi keybindings. Even the default Gmail keybindings are obviously (to a Vim user) based off of vi keybindings.
– Wildcard
Dec 21 '16 at 0:27
what about esc key does not work? Insert mode, just stopped.
– creator
Mar 10 '18 at 7:07
add a comment |
3
Oh man, shift and double z, what was the design logic behind that I wonder, "what's the least intuitive command we can create?", ubuntu sometimes pisses me off like mad
– S..
May 25 '14 at 11:10
4
@Sam, I just wanted to nitpick that vi has nothing in particular to do with ubuntu. Ubuntu was first released on 2004, while vi was created by Bill Joy around 1976, inspired by ed (dating back to 1971). This means that the shortcuts in vi predate those in almost any other still commonly used utility today. In a sort of coincidence, the first version of emacs, which has completely different weird shortcuts, was also released on 1976. Standardization efforts came much much later.
– yoniLavi
Nov 21 '14 at 2:00
Wow thanks for the info @yoniLavi , my points is still the same though, so hopefully standardization efforts keep advancing.. :)
– S..
Nov 21 '14 at 9:12
@Sam, vi keybindings are actually a lot more standard than you think; they're virtually ubiquitous. Practically any program can be made to emulate vi keybindings. Even the default Gmail keybindings are obviously (to a Vim user) based off of vi keybindings.
– Wildcard
Dec 21 '16 at 0:27
what about esc key does not work? Insert mode, just stopped.
– creator
Mar 10 '18 at 7:07
3
3
Oh man, shift and double z, what was the design logic behind that I wonder, "what's the least intuitive command we can create?", ubuntu sometimes pisses me off like mad
– S..
May 25 '14 at 11:10
Oh man, shift and double z, what was the design logic behind that I wonder, "what's the least intuitive command we can create?", ubuntu sometimes pisses me off like mad
– S..
May 25 '14 at 11:10
4
4
@Sam, I just wanted to nitpick that vi has nothing in particular to do with ubuntu. Ubuntu was first released on 2004, while vi was created by Bill Joy around 1976, inspired by ed (dating back to 1971). This means that the shortcuts in vi predate those in almost any other still commonly used utility today. In a sort of coincidence, the first version of emacs, which has completely different weird shortcuts, was also released on 1976. Standardization efforts came much much later.
– yoniLavi
Nov 21 '14 at 2:00
@Sam, I just wanted to nitpick that vi has nothing in particular to do with ubuntu. Ubuntu was first released on 2004, while vi was created by Bill Joy around 1976, inspired by ed (dating back to 1971). This means that the shortcuts in vi predate those in almost any other still commonly used utility today. In a sort of coincidence, the first version of emacs, which has completely different weird shortcuts, was also released on 1976. Standardization efforts came much much later.
– yoniLavi
Nov 21 '14 at 2:00
Wow thanks for the info @yoniLavi , my points is still the same though, so hopefully standardization efforts keep advancing.. :)
– S..
Nov 21 '14 at 9:12
Wow thanks for the info @yoniLavi , my points is still the same though, so hopefully standardization efforts keep advancing.. :)
– S..
Nov 21 '14 at 9:12
@Sam, vi keybindings are actually a lot more standard than you think; they're virtually ubiquitous. Practically any program can be made to emulate vi keybindings. Even the default Gmail keybindings are obviously (to a Vim user) based off of vi keybindings.
– Wildcard
Dec 21 '16 at 0:27
@Sam, vi keybindings are actually a lot more standard than you think; they're virtually ubiquitous. Practically any program can be made to emulate vi keybindings. Even the default Gmail keybindings are obviously (to a Vim user) based off of vi keybindings.
– Wildcard
Dec 21 '16 at 0:27
what about esc key does not work? Insert mode, just stopped.
– creator
Mar 10 '18 at 7:07
what about esc key does not work? Insert mode, just stopped.
– creator
Mar 10 '18 at 7:07
add a comment |
Check whether you have administrative (root) privileges to edit the file. use this command
whoami
If the result is not "root", then you are not supposed to edit the file.
To login as root user, use the below command
sudo su
or
su
Edit the file,
vi /etc/network/interfeces
After the changes, save the file using
- Press
Esc
to change the mode
:x
to save and quit the file
Thats all
add a comment |
Check whether you have administrative (root) privileges to edit the file. use this command
whoami
If the result is not "root", then you are not supposed to edit the file.
To login as root user, use the below command
sudo su
or
su
Edit the file,
vi /etc/network/interfeces
After the changes, save the file using
- Press
Esc
to change the mode
:x
to save and quit the file
Thats all
add a comment |
Check whether you have administrative (root) privileges to edit the file. use this command
whoami
If the result is not "root", then you are not supposed to edit the file.
To login as root user, use the below command
sudo su
or
su
Edit the file,
vi /etc/network/interfeces
After the changes, save the file using
- Press
Esc
to change the mode
:x
to save and quit the file
Thats all
Check whether you have administrative (root) privileges to edit the file. use this command
whoami
If the result is not "root", then you are not supposed to edit the file.
To login as root user, use the below command
sudo su
or
su
Edit the file,
vi /etc/network/interfeces
After the changes, save the file using
- Press
Esc
to change the mode
:x
to save and quit the file
Thats all
edited Feb 8 '13 at 16:04
answered Feb 8 '13 at 15:59
SathishSathish
51136
51136
add a comment |
add a comment |
this question was answered a long time ago, but in case it comes up in search engines again, this link is a nice vim cheatsheet that you might want to bookmark if you use vim a lot.
By the way, You can use :wq
to save and exit the file ( you should first press esc key to exit insert or replace mode and then press commands ) and use :q!
to exit without saving.
add a comment |
this question was answered a long time ago, but in case it comes up in search engines again, this link is a nice vim cheatsheet that you might want to bookmark if you use vim a lot.
By the way, You can use :wq
to save and exit the file ( you should first press esc key to exit insert or replace mode and then press commands ) and use :q!
to exit without saving.
add a comment |
this question was answered a long time ago, but in case it comes up in search engines again, this link is a nice vim cheatsheet that you might want to bookmark if you use vim a lot.
By the way, You can use :wq
to save and exit the file ( you should first press esc key to exit insert or replace mode and then press commands ) and use :q!
to exit without saving.
this question was answered a long time ago, but in case it comes up in search engines again, this link is a nice vim cheatsheet that you might want to bookmark if you use vim a lot.
By the way, You can use :wq
to save and exit the file ( you should first press esc key to exit insert or replace mode and then press commands ) and use :q!
to exit without saving.
edited Oct 27 '18 at 9:54
answered Aug 28 '17 at 9:56
razieh babaeerazieh babaee
1067
1067
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- 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%2faskubuntu.com%2fquestions%2f252760%2fhow-do-i-save-files-edited-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
6
If you are not comfortable with editing files in terminal based editors like
vi
orvim
, I would recommend using graphical based editor likegedit
to open them. Replacesudo vi
withgksu gedit
.– Aditya
Feb 8 '13 at 15:15
5
Or use
sudo nano
Its also command line but a lot more intuitive than vi.– Warren Hill
Oct 19 '13 at 9:46