Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to reload a .vimrc file in Linux/Unix without restarting Vim

Shulou Source: shulou.com Published: 2022-06-01 06:08:59 09月26日 Update

This article mainly shows you "how to reload .vimrc file without restarting Vim in Linux/Unix". The content is easy to understand and clear. I hope it can help you solve your doubts. Let me lead you to study and learn how to reload .vimrc file without restarting Vim in Linux/Unix.

I usually use: vs ~ / .vimrc to load ~ / .vimrc configuration. When editing .vimrc, I need to reload it without restarting the Vim session. On Linux or Unix-like systems, how do you reload .vimrc without restarting Vim after editing it?

Vim is a free, open source and up-compatible editor for Vi. It can be used to edit all kinds of text. It is especially useful when editing programs written in C/Perl/Python. You can use it to edit the Linux/Unix configuration file. ~ / .vimrc is your personal Vim initialization and customization file.

How to reload .vimrc without restarting the Vim session

The process of reloading .vimrc in Vim without restarting:

Enter vim filename to start vim

Press Esc and then enter: vs ~ / .vimrc to load the vim configuration

Add a custom configuration like this:

Filetype indent plugin on

Set number

Syntax on

Use: wq to save the file and exit from ~ / .vimrc window

Enter any of the following commands to reload ~ / .vimrc::so $MYVIMRC or: source ~ / .vimrc.

Figure 1: edit ~ / .vimrc and reload it if needed without exiting vim, so you can continue editing the program.

: so [urce]! {file} this vim command reads the configuration from a given file such as ~ / .vimrc. As you typed, these commands are executed in normal mode. When you follow: global,: argdo,: windo,: bufdo, loop, or follow another command, the display is no longer updated when the command is executed.

How to set keys to edit and reload ~ / .vimrc

Follow these on your ~ / .vimrc:

"Edit vimr configuration filennoremap confe: e $MYVIMRC" Reload vims configuration filennoremap confr: source $MYVIMRC

Now you can edit ~ / .vimrc by pressing Esc and then typing confe. Press Esc, and then enter confr to reload. Some people like to use keys in .vimrc. So the above mapping becomes:

"Edit vimr configuration filennoremap ve: e $MYVIMRC" Reload vimr configuration filennoremap vr: source $MYVIMRC

The key is mapped to the\ key by default. So just type\ and then ve to edit the file. Press\ and then vr can reload ~ / vimrc.

This is done, and you can reload .vimrc without restarting Vim.

The above is all the contents of the article "how to reload a .vimrc file without restarting Vim in Linux/Unix". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: File input command configuration no content article program study help general free personal situation keystroke text easy to understand is in more useful Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Redmi Xiaomi vpn OPPO Reno