Add jumps command for displaying the jump list (#1233)
* Add `jumps` command for displaying the jump list * Mention jump count in documentation * Reverse order
This commit is contained in:
1 parent
2a5c54c81a
commit
24e224ca65
6 files changed
+53
No files matched your search
@@ -1056,6 +1056,30 @@ func listBinds(binds map[string]expr) *bytes.Buffer {
|
||||
return b
|
||||
}
|
||||
|
||||
func listJumps(jumps []string, ind int) *bytes.Buffer {
|
||||
t := new(tabwriter.Writer)
|
||||
b := new(bytes.Buffer)
|
||||
|
||||
maxlength := len(strconv.Itoa(max(ind, len(jumps)-1-ind)))
|
||||
|
||||
t.Init(b, 0, gOpts.tabstop, 2, '\t', 0)
|
||||
fmt.Fprintln(t, " jump\tpath")
|
||||
// print jumps in order of most recent, Vim uses the opposite order
|
||||
for i := len(jumps) - 1; i >= 0; i-- {
|
||||
switch {
|
||||
case i < ind:
|
||||
fmt.Fprintf(t, " %*d\t%s\n", maxlength, ind-i, jumps[i])
|
||||
case i > ind:
|
||||
fmt.Fprintf(t, " %*d\t%s\n", maxlength, i-ind, jumps[i])
|
||||
default:
|
||||
fmt.Fprintf(t, "> %*d\t%s\n", maxlength, 0, jumps[i])
|
||||
}
|
||||
}
|
||||
t.Flush()
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
func listMarks(marks map[string]string) *bytes.Buffer {
|
||||
t := new(tabwriter.Writer)
|
||||
b := new(bytes.Buffer)
|
||||
|
||||
Reference in new issue
Block a user