Kakoune: Jump directly to file position

Created on 20 Jul 2020  路  6Comments  路  Source: mawww/kakoune

Feature

kak src/lib.rs:15:10
:e src/lib.rs:15:10

Jump directly to file on line and column specified.

Usecase

$ cargo check
    Checking ascii v0.1.0 (/home/ivan/ascii)
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `USIZE_SIZE`
  --> src/lib.rs:15:10
   |
15 |     onst USIZE_SIZE: usize = mem::size_of::<usize>();
   |          ^^^^^^^^^^ expected one of 8 possible tokens

error: aborting due to previous error

error: could not compile `ascii`.

To learn more, run the command again with --verbose.

It would be troublesome to manually copy src/lib.rs from src/lib.rs:15:10, also it would be good to jump to the specified line and column if it's specified. 15 denotes the line and 10 denotes the column.

feature request

Most helpful comment

Most compilers produce GCC-compatible file/line/column/message output, or can be configured to do so, so they work nicely with Kakoune's :make command. rustc doesn't, though, so you may be interested in my kakoune-cargo plugin which makes it a lot easier to jump from an error message to the corresponding location in the source file.

All 6 comments

Most compilers produce GCC-compatible file/line/column/message output, or can be configured to do so, so they work nicely with Kakoune's :make command. rustc doesn't, though, so you may be interested in my kakoune-cargo plugin which makes it a lot easier to jump from an error message to the corresponding location in the source file.

Yeah, {make,cargo}-next-error work wonders here.

I sometimes have file:line:col locations in other buffers, or in the system clipboard.
To deal with those two I use these commands:

define-command goto-file-at-cursor -docstring 'like "gf" but with smart filename:line:column detection" %{
    execute-keys %{<a-a><a-w>s([^:]+)(?::(\d+))?(?::(\d+))?<ret>) }
    edit -existing -- %reg{1} %reg{2} %reg{3}
}
define-command -override edit-location -params 1 -file-completion %{
    evaluate-commands %sh{
        echo "edit -- $1" | sed 's/:/ /g'
    }
}

Actually, this wasn't meant for rust. I just use rust as an example here because it also produce the same output. For rust, I usually type in the filename because it is short. But I actually meant for angular, it also produce the same output.

:edit src/lib.rs 15 10

From the command-line

kak <file> +<line>:<column>

From Kakoune

edit <file> <line> <column>

Why not support <file>:<line>:<column> for both command line and kakoune? Like check for this pattern if it does not match filename.

And how does kak <file> +<line>:<column> apply when multiple files are specified?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

abitofalchemy picture abitofalchemy  路  3Comments

lenormf picture lenormf  路  3Comments

radare picture radare  路  3Comments

hwmack picture hwmack  路  4Comments

basbebe picture basbebe  路  4Comments