简体   繁体   中英

Is there any option in vim similar to “nano -R”

nano editor has restricted mode "-R" to open a file where no other files can be opened from the editor and the user can modify only that specific file. Is there any option similar to that in vim editor where the user will not be able to use ":edit" option and open some other file and modify it.

The vim restricted mode option "vim -Z" restricts the editor to use the shell commands. But I need an option to restrict open any other file apart from the specified one.

No, there isn't such option, and it would probably be difficult to add (and mess up the source code quite a bit), because there are so many commands that potentially can open / write to different files.

If you need this, I would recommend to rely on the underlying operating system's means for protection, and do something like sudoedit :

Write a wrapper script that temporarily copies the file to a temporary location, and then invoke Vim with a restricted user that ideally can only access that single file. After Vim exits, copy back the file to its original location.

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