Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close vim editor with non-zero return value?

Tags:

vim

I have an alias bed="vim ~/.bashrc && . ~/.bashrc" in my .bashrc. Now every now and then I'd like to run bed but return the vim with an exit status 1 so the source command doesn't execute.

like image 313
kub1x Avatar asked Mar 30 '17 09:03

kub1x


People also ask

How do I end a Vim editor?

TL;DR – How to Exit Vim If you made some changes and would like to keep them, type :wq and press Enter / return. If you made some changes and would rather discard them, type :q! and press Enter / return.

How do I exit Vim editor in terminal?

You can press the Esc key. Type SHIFT Z Z to save and exit. Type SHIFT Z Q to exit without saving.

How do I exit Vim in terminal without saving?

Quit Vim / Vi without Saving the File To exit the editor, without saving the changes, switch to normal mode by pressing Esc , type :q! and hit Enter . Type :q!


1 Answers

Found the answer here : How to exit the Vim editor?

You can do :cq to exit with a non-zero exit code.

like image 65
Ealhad Avatar answered Oct 01 '22 06:10

Ealhad