Vim is free and open source text editor that is upwards compatible to Vi. It can be used to edit all kinds of good old text. It is especially useful for editing programs written in C/Perl/Python. One can use it for editing Linux/Unix configuration files. ~/.vimrc is your personal Vim initializations and customization file.
How to reload .vimrc file without restarting vim session
The procedure to reload .vimrc in Vim without restart:
- Start vim text editor by typing: vim filename
- Load vim config file by typing vim command: Esc followed by :vs ~/.vimrc
- Add customization like:
filetype indent plugin on
set number
syntax on - Use :wq to save a file and exit from ~/.vimrc window.
- Reload ~/.vimrc by typing any one of the following command:
:so $MYVIMRC
OR
:source ~/.vimrc
Fig.01: Editing ~/.vimrc and reloading it when needed without quiting vim so that you can continuing editing program
How to may keys for edit and reload ~/.vimrc
Append the following in your ~/.vimrc file
" Edit vimr configuration file
nnoremap confe :e $MYVIMRC<CR>
" Reload vims configuration file
nnoremap confr :source $MYVIMRC<CR>
Now just press Esc followed by confe to edit ~/.vimrc file. To reload type Esc followed by confr. Some people like to use the <Leader> key in a .vimrc file. So above mapping becomes:
" Edit vimr configuration file nnoremap <Leader>ve :e $MYVIMRC<CR> " " Reload vimr configuration file nnoremap <Leader>vr :source $MYVIMRC<CR>
The <Leader> key is mapped to \ by default. So you just press \ followed by ve to edit the file. To reload the ~/vimrc file you press \ followed by vr
And there you have it, you just reload .vimrc file without restarting vim ever.
- How To Exit From top Command In Linux / Unix / BSD / OS X
- How To Exit Vim Text Editor Command
- Vi / Vim: Save And Quit The Editor Command
- How to reload .vimrc file without restarting vim on Linux/Unix
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 0 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |