Vim ignores files in /usr/share/vim/vim90/ because that directory is strictly for runtime defaults, not user configuration. User settings must be placed in ~/.vimrc or ~/.config/nvim/init.vim. Moving your custom scripts to the correct location resolves the issue immediately without changing permissions.
Understanding Vim’s Directory Structure
To troubleshoot why Vim appears to ignore your configuration files in/usr/share/vim/vim90/, you must first understand how Vim organizes its file system. The directory structure is divided into two distinct categories: system-wide defaults and user-specific configurations. This separation ensures that package managers can update Vim safely without overwriting personal preferences.
The path /usr/share/vim/vim90/ (or similar versioned paths like vim82) resides within the system share area. Files here are owned by the root user and are read-only for standard users. They contain the default behavior of Vim, such as syntax highlighting rules, basic key mappings, and plugin templates provided by the Fedora distribution. When you place a file here, you are modifying the base image of the editor.
Vim explicitly skips sourcing most files from this directory during startup unless they are specifically designated as runtime defaults. It does not treat them as active configuration files. If you have placed a script intended to change your theme or define aliases in this folder, Vim will silently ignore it. This is not a bug; it is a security and stability feature. Modifying these files can lead to conflicts during updates, where the package manager might reset your changes or fail due to permission errors.
For user customization, Vim looks exclusively at the home directory. The primary file is ~/.vimrc for Vim 8 and 9. For Neovim, which shares much of the ecosystem, the path is ~/.config/nvim/init.vim. These locations are writable by the user and are sourced automatically every time the editor launches. If your commands are not working, check if they are in the wrong directory rather than assuming the editor is broken.
The Role of Permissions
A common misconception is that changing permissions on/usr/share/vim/vim90/ will force Vim to read your files. You should never run chmod 755 or chmod 644 on system directories. Doing so breaks the integrity checks performed by package managers like DNF on Fedora. It can also expose the system to security vulnerabilities if malicious scripts are introduced. The silence you observe is Vim respecting the read-only nature of the system directory, not failing to access it.
If you need to extend functionality provided in the system directory, use the runtime! glob() command in your ~/.vimrc to source specific files from the system path, or better yet, install plugins via a plugin manager like vim-plug or packer.nvim. These tools handle dependencies and placement correctly, ensuring your customizations remain separate from system defaults.
Correcting Your Configuration Path
To fix the issue, move your configuration files out of/usr/share/vim/vim90/ and into your home directory. First, identify the settings you wish to apply. Common examples include setting line numbers, enabling mouse support, or defining custom key bindings.
Create or edit the file ~/.vimrc using any text editor. Add your desired commands to this file. For example, to enable line numbers, add set number. To map a key, use nnoremap. Save the file and restart Vim. Your changes should now take effect.
If you are using a plugin manager, ensure that your initialization code is also in ~/.vimrc or a dedicated init.vim file. Plugin managers expect to find their configuration in user-space directories. Plugging them into the system directory will prevent them from loading correctly.
Verifying File Sourcing
You can verify which files Vim is sourcing by running:scriptnames in command-line mode. This command lists all scripts that were loaded during startup. Look for ~/.vimrc in the output. If it is missing, Vim did not find the file. Check the spelling and location. Ensure there are no typos in the filename.
If you suspect a conflict, you can debug further by starting Vim with vim -u NONE. This disables all configuration files. If your settings work when manually entered, the issue is likely a syntax error in your ~/.vimrc. Use :messages to view any error logs generated during startup.
Related Resources
If you are dealing with complex editing tasks, understanding how to manipulate text efficiently is crucial. For instance, you might want to merge lines based on delimiters. See our guide on Merging Lines with Semicolon in VIM: A Comprehensive Guide for advanced text manipulation techniques. Additionally, if you are configuring key mappings and find that your shortcuts are not responding as expected, check for conflicts with existing mappings. Our article on Fixing Vim: Map Command Not Working Correctly with F2 Key provides detailed troubleshooting steps for mapping issues.Frequently Asked Questions
Why does Vim ignore my .vimrc file?
Vim ignores your .vimrc if it is located in the wrong directory or named incorrectly. Ensure the file is named exactly .vimrc and resides in your home directory (~). Check for hidden characters or typos in the filename.
Can I modify files in /usr/share/vim/vim90/ permanently?
No, you should not modify files in this directory. Package updates will overwrite your changes, and altering system files can break the operating system's integrity. Use ~/.vimrc for all persistent customizations instead.
How do I check which config files Vim is loading?
Run the command :scriptnames inside Vim. This displays a list of all sourced scripts. Look for .vimrc or init.vim to confirm your configuration was loaded successfully.
What is the difference between .vimrc and init.vim?
.vimrc is used by Vim 8 and Vim 9, while init.vim is used by Neovim. They serve the same purpose but are interpreted by different editors. Do not mix them up if you switch between Vim and Neovim.
Why are my key mappings not working after moving configs?
Your key mappings may not work if they are defined before other plugins load. Move your mappings to the end of .vimrc or use autocmd events to ensure they execute after initialization. Also, verify that no other plugin is overriding your mappings.