-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvim.js
More file actions
89 lines (81 loc) · 2.62 KB
/
vim.js
File metadata and controls
89 lines (81 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
(function() {
var stack = new document.$.Stack;
document.addEventListener('keydown', function(e) {
if (document.$.focused()) return;
if (e.shiftKey) {
var height = document.documentElement.scrollHeight;
if (e.which === 71) {
// console.log('G');
window.scrollBy({
top: height
});
} else if (e.which === 72) {
// console.log('H');
window.scroll({
top: 0
});
} else if (e.which === 77) {
// console.log("m");
window.scroll({
top: height / 2
});
} else if (e.which === 74) {
// console.log('J');
// chrome default scroll 40px using arrow keys
window.scrollBy({
top: 1
});
} else if (e.which === 75) {
// console.log('K');
window.scrollBy({
top: -1
});
}
} else if (e.ctrlKey) {
var page = Math.floor(window.innerHeight / 50) * 50;
if (e.which === 70) {
// console.log('f');
// default action is bookmark
e.preventDefault();
window.scrollBy({
top: page
});
} else if (e.which === 85) {
// console.log('u');
// default action is source code
e.preventDefault();
window.scrollBy({
top: -page
});
}
} else if (e.metaKey) {
// console.log("e.metaKey", e.metaKey);
} else if (e.altKey) {
// console.log("e.altKey", e.altKey);
} else {
// check combination key shortcuts firstly
stack.push(e.which);
stack.match('gg', function() {
window.scroll({
top: 0
});
return;
});
if (e.which === 27) {
// console.log('Escape');
stack.clear();
} else if (e.which === 74) {
// console.log('j');
// chrome default scroll 40px using arrow keys
window.scrollBy({
top: 50
});
} else if (e.which === 75) {
// console.log('k');
window.scrollBy({
top: -50
});
}
}
});
})();