在 Vim 编辑器中为 NERDTree 创建命令快捷方式

发布于 2024-11-17 03:52:21 字数 112 浏览 6 评论 0原文

我想在命令行上创建 NERDTree 的缩写。我发现每次我想启用它时都必须编写 :NERDTree ,这很烦人。所以我想输入 :nr 或类似的内容。这可能吗?

I'd like to create an abbreviation for NERDTree on the command-line. I find it annoying have to write :NERDTree every time I want to enable it. So I'd like to type :nr or something like that. Is that possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

寂寞清仓 2024-11-24 03:52:21

在我的 .vimrc 中,我有:

let mapleader = ","
nmap <leader>ne :NERDTree<cr>

因此,当我需要 NERDTree 时,我只需在正常模式下编写 ,ne 即可。

In my .vimrc I have:

let mapleader = ","
nmap <leader>ne :NERDTree<cr>

So when I need NERDTree I just write ,ne in normal mode.

§普罗旺斯的薰衣草 2024-11-24 03:52:21

我发现这非常有效,比我尝试过的任何其他建议都要好:

map <silent> <C-n> :NERDTreeFocus<CR>

您只需按 control-n 即可返回层次结构。当然,在层次结构中选择一个文件名会将您切换到该文件。

  1. 它在正常和插入模式下都可以工作
  2. 它不会像接受的答案那样关闭层次结构(使用 :NERDTree 命令从头开始,关闭层次结构,同时使用 :NERDTreeFocus< /code> 只是移动焦点,我认为这就是你想要的)

I find this works very nicely, better than any other suggestions I've tried:

map <silent> <C-n> :NERDTreeFocus<CR>

You just hit control-n to go back to the hierarchy. Selecting a file name in the hierarchy will switch you, of course, to that file.

  1. It works in both normal and insert mode
  2. It doesn't close the hierarchy as the accepted answer does (using the :NERDTree command starts you from scratch, closing the hierarchy, while using :NERDTreeFocus simply moves the focus, which I think is what you want)
云巢 2024-11-24 03:52:21

要进行切换,请使用以下命令:

map;:NERDTreeToggle

To toggle, use the following:

map <silent> <C-n> :NERDTreeToggle<CR>

独自←快乐 2024-11-24 03:52:21

对于前 Sublime 用户:

map <silent> <C-k>b :NERDTreeToggle<CR>

For ex Sublime users:

map <silent> <C-k>b :NERDTreeToggle<CR>
当爱已成负担 2024-11-24 03:52:21

添加到你的 rc 文件(.bashrc / .zshrc)这个快捷方式

alias nerd="nvim -c \"NERDTree\""

,然后重新加载你的 bash 宽度

source ~/.zshrc # or ~/.bashrc according your case

并运行

nerd

-c 标志允许你在启动终端时执行命令

nvim -c "command"

add to your rc file (.bashrc / .zshrc) this shortcut

alias nerd="nvim -c \"NERDTree\""

then, reload your bash width

source ~/.zshrc # or ~/.bashrc according your case

and run

nerd

the -c flag allows you to execute a command when starting the terminal

nvim -c "command"
疯狂的代价 2024-11-24 03:52:21

.vimrc:

let mapleader = "n" #nerdtree  
nmap <leader> :NERDTreeFocus<cr>
let mapleader = "f" #focus
nmap <leader> :NERDTreeToggle<cr>

.bash_profile:

alias n="vim -c 'NERDTree'"

.vimrc:

let mapleader = "n" #nerdtree  
nmap <leader> :NERDTreeFocus<cr>
let mapleader = "f" #focus
nmap <leader> :NERDTreeToggle<cr>

.bash_profile:

alias n="vim -c 'NERDTree'"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文