Vim PHP Tab 跳转到语句后的下一个空行

发布于 2024-11-15 14:40:20 字数 853 浏览 2 评论 0原文

我在使用 macvim 编辑 PHP 文件时遇到一个奇怪的问题。当我按 Tab 时,它不会给我一个制表符或一系列空格,而是在任何一系列语句之后跳到一个空行。它将对整个文件执行此操作,直到到达末尾。例如,在下面的代码片段中,如果我将光标放在“$products”前面并按下制表符,则不会插入制表符或空格,并且光标将落在其下方的空行上

  public function index()
  {
     // get a distinct list of product names
     $products = $this->license_model->get_all_product_names();

     // get all records and fields from the view
     $records = $this->license_model->get_all_records();

     // assign objects to the array to pass to the view
     $data = array(
        'products' => $products,
        'records' => $records
     );

     // load the view
     $this->load->view('home.php', $data);
  }

:如果选中 $data 数组上方的注释,光标将移动到下一个注释“加载视图”上方的行。

使用vim命令>>但是,会按预期缩进该行。问题似乎仅与 *.php 文件有关。在 *.java 文件中按 Tab 键可以正常工作。

我有什么想法可以解决这个问题吗?

谢谢

I'm having an odd problem with editing PHP files with macvim. When I press tab, instead of giving me a tab or series of spaces, it instead jumps down to a blank line after any series of statements. It will do this through the entire file until it reaches the end. For example, in the following snippet, if I have my cursor in front of "$products" and pressed tab, no tab or space would be inserted, and the cursor would land on the empty line below it:

  public function index()
  {
     // get a distinct list of product names
     $products = $this->license_model->get_all_product_names();

     // get all records and fields from the view
     $records = $this->license_model->get_all_records();

     // assign objects to the array to pass to the view
     $data = array(
        'products' => $products,
        'records' => $records
     );

     // load the view
     $this->load->view('home.php', $data);
  }

If I was to try and tab the comment above the $data array, the cursor would move to the line just above the next comment "load the view".

Using the vim command >> will indent the line as expected, however. The problem only seems to be with *.php files. Tabbing in say a *.java file works as normal.

Any ideas how I can fix this?

Thanks

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

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

发布评论

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

评论(1

云仙小弟 2024-11-22 14:40:20

听起来好像某些东西已将插入模式下的 映射到某些东西。通过发出以下命令查看为 定义了哪些映射:

:verbose map <Tab>

这应该输出当前设置的所有映射以及哪个文件设置了这些映射(以便您可以删除它们)。

Sounds like something has mapped <Tab> or <C-i> in insert mode to something. See what maps are defined for <Tab> by issuing:

:verbose map <Tab>

This should output any mappings that are currently set up and which file set these mappings (so you may remove them).

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