简体   繁体   中英

Apply changes to .vimrc to source file

Im currently making a lot of changes in my .vimrc. At the same time Im also coding away on a project. To fix the new indentation and tabstop rules, and so on, I have to go through every line and re-indent them. This seems a little bit tedious.

Is there any way to apply the newest changes in my .vimrc to the whole source file?

Your problem seems to be that existing buffers do not get the updated (global) values of eg 'tabstop' , because these are buffer-local options. Therefore, a simple :so % after editing the ~/.vimrc isn't sufficient.

There are several possible approaches:

Use sessions

With the current Vim state persisted via :mksession , you can safely :quit Vim, restart it, :so session.vim , and have the identical editing state, but with the new settings applied (this requires that you :set sessionoptions-=options )

Manually apply

You can eg :yank the changed :set tabstop=... commands that you've edited and reapply them to all existing buffers, eg by moving there and :@" , or (if there are many) with the help of :bufdo .


Note that especially the indent settings can also be set from ftplugins , so your global settings may not be effective. You can check that for a buffer with :verbose set tabstop? .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM