Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report