Vim_Open_With_Vim in right click

本文介绍如何在Linux系统中通过编辑defaults.list文件并新建vim.desktop文件,实现右键菜单直接使用vim编辑文件的功能。同时,提供Windows系统的注册表修改方法,同样可以实现类似效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、linux系统下

每次使用vim需要从终端进入相应目录然后打开文件进行编辑,这样总感觉很麻烦,我们可以自己在右键添加一个使用vim编辑的选项,步骤如下:

  • 1、用vim编辑defaults.list,把所有的gedit.desktop用vim.desktop 来替换。命令如下:
    sudo vim /etc/gnome/defaults.list
    
    在vim中输入
    :%s/gedit.desktop/vim.desktop/g
    
  • 2、在/usr/share/applications下新建一个vim.desktop文件
sudo vim /usr/share/applications/vim.desktop

里面编辑内容如下:

	[Desktop Entry]
		Encoding=UTF-8
		Type=Application
		Exec=vim %f
		Icon=/usr/share/vim/vim48x48.png
		Name=Vim
		Terminal=true
		NoDisplay=true

这样右键菜单中就可以使用vim打开文件了。

 

Windows下:

 

1.在运行里面输入 redegit ,地球人都知道,这是打开windows的注册表。 

2.依次打开HKEY_CLASSES_ROOT/*/shell,有点点击shell,新建项,输入项的名字,这是要在右键里显示的,建议输入Edit with Gvim. 

3.右键点击刚建的 Edit With Gvim 项,再新建项,名字为 command , 修改其值为 C:\Program Files\Vim\vim73\gvim.exe "%1" 

修改为: C:\Program Files\Vim\vim73\gvim.exe  -p --remote-tab-silent  "%1"

"vim" is not recognized as an internal or external command, operable program or batch file. This error typically occurs when the "vim" command-line text editor is not installed or not properly configured on your system. Here are a few steps you can take to resolve this issue: 1. Install Vim: If you haven't installed Vim yet, you can download it from the official Vim website (https://www.vim.org/download.php) and follow the installation instructions for your operating system. Make sure to add Vim to your system's PATH environment variable during the installation process. 2. Check PATH variable: If you have already installed Vim, it's possible that its installation directory is not included in your system's PATH environment variable. To check this, open a command prompt and run the following command: ``` echo %PATH% ``` Look for the directory where Vim is installed (e.g., "C:\Program Files\Vim") in the output. If it's missing, you need to add it manually: - Open the System Properties dialog by right-clicking on My Computer/This PC and selecting "Properties". - Click on "Advanced system settings" or "Advanced" tab. - Click on the "Environment Variables" button. - In the "System variables" section, select the "Path" variable and click on "Edit". - Add the directory path of your Vim installation (e.g., "C:\Program Files\Vim") at the end of the variable value, separating it from the previous entry with a semicolon (;). - Click "OK" to save the changes. 3. Restart your command prompt: After making any changes to the PATH variable, you need to close and reopen your command prompt for the changes to take effect. Once you've done that, try running the "vim" command again to see if it works. If the issue persists, please ensure that you have installed Vim correctly and that it is accessible from the command prompt.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值