From 53fa90f23e51a0aecf94e5be7db577997e87a7b6 Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Sat, 7 Mar 2026 14:25:25 +0200 Subject: [PATCH 01/24] implement correct median calculation --- Sprint-1/fix/median.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Sprint-1/fix/median.js b/Sprint-1/fix/median.js index b22590bc6..f7d2fd653 100644 --- a/Sprint-1/fix/median.js +++ b/Sprint-1/fix/median.js @@ -6,9 +6,21 @@ // or 'list' has mixed values (the function is expected to sort only numbers). function calculateMedian(list) { - const middleIndex = Math.floor(list.length / 2); - const median = list.splice(middleIndex, 1)[0]; - return median; + // Filter out non-numeric values and sort the remaining numbers + const numbers = list + .filter((x) => typeof x === "number" && !isNaN(x)) + .sort((a, b) => a - b); + + if (numbers.length === 0) { + return null; + } + + const mid = Math.floor(numbers.length / 2); + if (numbers.length % 2 === 0) { + return (numbers[mid - 1] + numbers[mid]) / 2; + } else { + return numbers[mid]; + } } module.exports = calculateMedian; From 7b40348f4155773d1a213c8e13496d8500a58987 Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Thu, 26 Mar 2026 14:37:52 +0200 Subject: [PATCH 02/24] Access houseNumber correctly from address object --- Sprint-2/debug/address.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/debug/address.js b/Sprint-2/debug/address.js index 940a6af83..36d2f865d 100644 --- a/Sprint-2/debug/address.js +++ b/Sprint-2/debug/address.js @@ -12,4 +12,4 @@ const address = { postcode: "XYZ 123", }; -console.log(`My house number is ${address[0]}`); +console.log(`My house number is ${address.houseNumber}`); From c04e2dc1255c8bf9e7acb1c41a84c5e7428bdd21 Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Thu, 26 Mar 2026 14:40:53 +0200 Subject: [PATCH 03/24] Use Object.values to loop through author object --- Sprint-2/debug/author.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/debug/author.js b/Sprint-2/debug/author.js index 8c2125977..7ba8f4c75 100644 --- a/Sprint-2/debug/author.js +++ b/Sprint-2/debug/author.js @@ -11,6 +11,6 @@ const author = { alive: true, }; -for (const value of author) { +for (const value of Object.values(author)) { console.log(value); } From 59fff2a0355a298a4484efa664f45d3a313aa9f8 Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Thu, 26 Mar 2026 14:44:47 +0200 Subject: [PATCH 04/24] display ingredients correctly instead of object --- Sprint-2/debug/recipe.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/debug/recipe.js b/Sprint-2/debug/recipe.js index 6cbdd22cd..a413b3332 100644 --- a/Sprint-2/debug/recipe.js +++ b/Sprint-2/debug/recipe.js @@ -12,4 +12,4 @@ const recipe = { console.log(`${recipe.title} serves ${recipe.serves} ingredients: -${recipe}`); +${recipe.ingredients.join("\n")}`); From bbdc491327434b3e93b44823a27f0c1968d7151b Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Thu, 26 Mar 2026 15:40:42 +0200 Subject: [PATCH 05/24] Add contains function to check if value exists in array --- Sprint-2/implement/contains.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-2/implement/contains.js b/Sprint-2/implement/contains.js index cd779308a..f2f9e932c 100644 --- a/Sprint-2/implement/contains.js +++ b/Sprint-2/implement/contains.js @@ -1,3 +1,5 @@ -function contains() {} +function contains(array, value) { + return array.includes(value); +} module.exports = contains; From 904055c3c30c2793cae0e529e709b1015383b4ee Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Thu, 26 Mar 2026 15:47:29 +0200 Subject: [PATCH 06/24] implement contains function for object property check --- Sprint-2/implement/contains.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sprint-2/implement/contains.js b/Sprint-2/implement/contains.js index f2f9e932c..084d6f114 100644 --- a/Sprint-2/implement/contains.js +++ b/Sprint-2/implement/contains.js @@ -1,5 +1,8 @@ -function contains(array, value) { - return array.includes(value); +function contains(obj, key) { + if (typeof obj !== "object" || obj === null || Array.isArray(obj)) { + return false; + } + return key in obj.hasOwnProperty(key); } module.exports = contains; From 7f287698c1292eda1c9e687db131a2321e76a0ee Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Thu, 26 Mar 2026 15:53:34 +0200 Subject: [PATCH 07/24] implement contains test cases --- Sprint-2/implement/contains.test.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Sprint-2/implement/contains.test.js b/Sprint-2/implement/contains.test.js index 326bdb1f2..112021add 100644 --- a/Sprint-2/implement/contains.test.js +++ b/Sprint-2/implement/contains.test.js @@ -20,16 +20,34 @@ as the object doesn't contains a key of 'c' // Given an empty object // When passed to contains // Then it should return false -test.todo("contains on empty object returns false"); +test("returns false for an empty object", () => { + expect(contains({}, "a")).toBe(false); +}); // Given an object with properties // When passed to contains with an existing property name // Then it should return true +test("returns true for an existing property", () => { + expect(contains({ a: 1, b: 2 }, "a")).toBe(true); +}); // Given an object with properties // When passed to contains with a non-existent property name // Then it should return false +test("returns false for a non-existent property", () => { + expect(contains({ a: 1, b: 2 }, "c")).toBe(false); +}); // Given invalid parameters like an array // When passed to contains // Then it should return false or throw an error +test("returns false for an array", () => { + expect(contains([], "a")).toBe(false); +}); + +// Given invalid parameters like null +// When passed to contains +// Then it should return false or throw an error +test("returns false for null", () => { + expect(contains(null, "a")).toBe(false); +}); From e6ec9d44e01fc039f1726d64f3407ffab2d8e031 Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Thu, 26 Mar 2026 15:55:21 +0200 Subject: [PATCH 08/24] Made it look clean --- Sprint-2/implement/contains.test.js | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/Sprint-2/implement/contains.test.js b/Sprint-2/implement/contains.test.js index 112021add..b8008fb38 100644 --- a/Sprint-2/implement/contains.test.js +++ b/Sprint-2/implement/contains.test.js @@ -1,24 +1,7 @@ const contains = require("./contains.js"); -/* -Implement a function called contains that checks an object contains a -particular property - -E.g. contains({a: 1, b: 2}, 'a') // returns true -as the object contains a key of 'a' - -E.g. contains({a: 1, b: 2}, 'c') // returns false -as the object doesn't contains a key of 'c' -*/ - -// Acceptance criteria: - -// Given a contains function -// When passed an object and a property name -// Then it should return true if the object contains the property, false otherwise - // Given an empty object -// When passed to contains +// When passed to contains with any key // Then it should return false test("returns false for an empty object", () => { expect(contains({}, "a")).toBe(false); From 067f3e1eaae63456d6223b7b9b85881a620feb16 Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Thu, 26 Mar 2026 16:02:05 +0200 Subject: [PATCH 09/24] Implement createLookup function for country-currency pairs --- Sprint-2/implement/lookup.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Sprint-2/implement/lookup.js b/Sprint-2/implement/lookup.js index a6746e07f..16f8daeae 100644 --- a/Sprint-2/implement/lookup.js +++ b/Sprint-2/implement/lookup.js @@ -1,5 +1,12 @@ -function createLookup() { - // implementation here +function createLookup(pairs) { + const result = {}; + for (let i = 0; i < pairs.length; i++) { + const country = pairs[i][0]; + const currency = pairs[i][1]; + + result[country] = currency; + } + return result; } module.exports = createLookup; From 5b88737258c320892fdc7906f0fc9a51ac242d10 Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Thu, 26 Mar 2026 16:12:37 +0200 Subject: [PATCH 10/24] set up jest and add test script --- Sprint-2/implement/lookup.test.js | 50 ++++++++++--------------------- package.json | 8 +++++ 2 files changed, 23 insertions(+), 35 deletions(-) create mode 100644 package.json diff --git a/Sprint-2/implement/lookup.test.js b/Sprint-2/implement/lookup.test.js index 547e06c5a..88bbc4fc9 100644 --- a/Sprint-2/implement/lookup.test.js +++ b/Sprint-2/implement/lookup.test.js @@ -1,35 +1,15 @@ -const createLookup = require("./lookup.js"); - -test.todo("creates a country currency code lookup for multiple codes"); - -/* - -Create a lookup object of key value pairs from an array of code pairs - -Acceptance Criteria: - -Given - - An array of arrays representing country code and currency code pairs - e.g. [['US', 'USD'], ['CA', 'CAD']] - -When - - createLookup function is called with the country-currency array as an argument - -Then - - It should return an object where: - - The keys are the country codes - - The values are the corresponding currency codes - -Example -Given: [['US', 'USD'], ['CA', 'CAD']] - -When -createLookup(countryCurrencyPairs) is called - -Then -It should return: - { - 'US': 'USD', - 'CA': 'CAD' - } -*/ +test("creates a lookup object from an array of country-currency pairs", () => { + const countryCurrencyPairs = [ + ["US", "USD"], + ["CA", "CAD"], + ["GB", "GBP"], + ]; + + const lookup = createLookup(countryCurrencyPairs); + + expect(lookup).toEqual({ + US: "USD", + CA: "CAD", + GB: "GBP", + }); +}); diff --git a/package.json b/package.json new file mode 100644 index 000000000..2efd299e9 --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "scripts": { + "test": "jest" + }, + "devDependencies": { + "jest": "^30.3.0" + } +} From 92c0f0435f48e43b5613c7a723880bf1065d2e86 Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Thu, 26 Mar 2026 16:49:31 +0200 Subject: [PATCH 11/24] 1. add createLookup test cases for multiple and empty inputs 2. correct import path for createLookup in tests 3.add jest and configure test script. --- Sprint-2/implement/lookup.js | 3 +-- Sprint-2/implement/lookup.test.js | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Sprint-2/implement/lookup.js b/Sprint-2/implement/lookup.js index 16f8daeae..de123209e 100644 --- a/Sprint-2/implement/lookup.js +++ b/Sprint-2/implement/lookup.js @@ -1,8 +1,7 @@ function createLookup(pairs) { const result = {}; for (let i = 0; i < pairs.length; i++) { - const country = pairs[i][0]; - const currency = pairs[i][1]; + const [country, currency] = pairs[i]; result[country] = currency; } diff --git a/Sprint-2/implement/lookup.test.js b/Sprint-2/implement/lookup.test.js index 88bbc4fc9..45fd9e0b0 100644 --- a/Sprint-2/implement/lookup.test.js +++ b/Sprint-2/implement/lookup.test.js @@ -1,15 +1,23 @@ -test("creates a lookup object from an array of country-currency pairs", () => { - const countryCurrencyPairs = [ +const createLookup = require("./lookup.js"); + +test("creates a country currency code lookup for multiple codes", () => { + const input = [ ["US", "USD"], ["CA", "CAD"], ["GB", "GBP"], ]; - - const lookup = createLookup(countryCurrencyPairs); - - expect(lookup).toEqual({ + const expected = { US: "USD", CA: "CAD", GB: "GBP", - }); + }; + + expect(createLookup(input)).toEqual(expected); +}); + +test("creates a country currency code lookup for an empty array", () => { + const input = []; + const expected = {}; + + expect(createLookup(input)).toEqual(expected); }); From 12f79f0bd916ba7777dc8d4e2b2f1cc6beb8dd82 Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Thu, 26 Mar 2026 22:28:58 +0200 Subject: [PATCH 12/24] Correctly parse query strings with '=' in values and edge cases" --- Sprint-2/implement/contains.js | 7 ++-- Sprint-2/implement/querystring.js | 28 ++++++++++------ Sprint-2/implement/querystring.test.js | 44 ++++++++++++++++++++++++-- 3 files changed, 63 insertions(+), 16 deletions(-) diff --git a/Sprint-2/implement/contains.js b/Sprint-2/implement/contains.js index 084d6f114..10b94ea28 100644 --- a/Sprint-2/implement/contains.js +++ b/Sprint-2/implement/contains.js @@ -1,8 +1,7 @@ function contains(obj, key) { - if (typeof obj !== "object" || obj === null || Array.isArray(obj)) { - return false; - } - return key in obj.hasOwnProperty(key); + if (!obj) return false; + + return Object.prototype.hasOwnProperty.call(obj, key); } module.exports = contains; diff --git a/Sprint-2/implement/querystring.js b/Sprint-2/implement/querystring.js index 45ec4e5f3..9e8fdff5d 100644 --- a/Sprint-2/implement/querystring.js +++ b/Sprint-2/implement/querystring.js @@ -1,16 +1,24 @@ function parseQueryString(queryString) { - const queryParams = {}; - if (queryString.length === 0) { - return queryParams; - } - const keyValuePairs = queryString.split("&"); + const result = {}; + if (!queryString) return result; - for (const pair of keyValuePairs) { - const [key, value] = pair.split("="); - queryParams[key] = value; - } + const pairs = queryString.split("&"); - return queryParams; + pairs.forEach((pair) => { + if (!pair) return; + + const index = pair.indexOf("="); + + if (index === -1) { + result[pair] = ""; + } else { + const key = pair.slice(0, index); + const value = pair.slice(index + 1); + result[key] = value; + } + }); + + return result; } module.exports = parseQueryString; diff --git a/Sprint-2/implement/querystring.test.js b/Sprint-2/implement/querystring.test.js index 3e218b789..fe2e1191a 100644 --- a/Sprint-2/implement/querystring.test.js +++ b/Sprint-2/implement/querystring.test.js @@ -3,10 +3,50 @@ // Below is one test case for an edge case the implementation doesn't handle well. // Fix the implementation for this test, and try to think of as many other edge cases as possible - write tests and fix those too. -const parseQueryString = require("./querystring.js") +const parseQueryString = require("./querystring.js"); test("parses querystring values containing =", () => { expect(parseQueryString("equation=x=y+1")).toEqual({ - "equation": "x=y+1", + equation: "x=y+1", + }); +}); + +test("parses multiple key-value pairs", () => { + expect(parseQueryString("name=Alice&age=30&city=NY")).toEqual({ + name: "Alice", + age: "30", + city: "NY", + }); +}); + +test("returns an empty object for an empty query string", () => { + expect(parseQueryString("")).toEqual({}); +}); + +test("handles key without equals sign", () => { + expect(parseQueryString("key1=value1&key2&key3=value3")).toEqual({ + key1: "value1", + key2: "", + key3: "value3", + }); +}); + +test("handles multiple '=' in value", () => { + expect(parseQueryString("data=a=b=c")).toEqual({ + data: "a=b=c", + }); +}); + +test("handles empty key", () => { + expect(parseQueryString("=value")).toEqual({ + "": "value", + }); +}); + +test("handles mixed querystring", () => { + expect(parseQueryString("a=1&b&c=3=d")).toEqual({ + a: "1", + b: "", + c: "3=d", }); }); From 3c7d55443f3d799ec8123fa43262c4b23c8d1544 Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Thu, 26 Mar 2026 22:36:22 +0200 Subject: [PATCH 13/24] Implement tally function with error handling and tests" --- Sprint-2/implement/tally.js | 18 +++++++++++++++++- Sprint-2/implement/tally.test.js | 10 +++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Sprint-2/implement/tally.js b/Sprint-2/implement/tally.js index f47321812..ee6181020 100644 --- a/Sprint-2/implement/tally.js +++ b/Sprint-2/implement/tally.js @@ -1,3 +1,19 @@ -function tally() {} +function tally(items) { + if (!Array.isArray(items)) { + throw new Error("Input must be an array"); + } + + const result = {}; + + items.forEach((item) => { + if (result[item]) { + result[item]++; + } else { + result[item] = 1; + } + }); + + return result; +} module.exports = tally; diff --git a/Sprint-2/implement/tally.test.js b/Sprint-2/implement/tally.test.js index 2ceffa8dd..a7565c99b 100644 --- a/Sprint-2/implement/tally.test.js +++ b/Sprint-2/implement/tally.test.js @@ -23,12 +23,20 @@ const tally = require("./tally.js"); // Given an empty array // When passed to tally // Then it should return an empty object -test.todo("tally on an empty array returns an empty object"); +test("tally on an empty array returns an empty object", () => { + expect(tally([])).toEqual({}); +}); // Given an array with duplicate items // When passed to tally // Then it should return counts for each unique item +test("tally on an array with duplicate items returns correct counts", () => { + expect(tally(["a", "a", "b", "c"])).toEqual({ a: 2, b: 1, c: 1 }); +}); // Given an invalid input like a string // When passed to tally // Then it should throw an error +test("tally on an invalid input throws an error", () => { + expect(() => tally("not an array")).toThrow("Input must be an array"); +}); From 78d5e4449b648c6b55a2ff54f06a2a9b461171be Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Thu, 26 Mar 2026 22:46:36 +0200 Subject: [PATCH 14/24] Correctly invert object keys and values using bracket notation" --- Sprint-2/interpret/invert.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Sprint-2/interpret/invert.js b/Sprint-2/interpret/invert.js index bb353fb1f..692539dbc 100644 --- a/Sprint-2/interpret/invert.js +++ b/Sprint-2/interpret/invert.js @@ -10,7 +10,7 @@ function invert(obj) { const invertedObj = {}; for (const [key, value] of Object.entries(obj)) { - invertedObj.key = value; + invertedObj[value] = key; } return invertedObj; @@ -27,3 +27,27 @@ function invert(obj) { // d) Explain why the current return value is different from the target output // e) Fix the implementation of invert (and write tests to prove it's fixed!) +const invert = require("./invert"); + +test("inverts a simple object", () => { + expect(invert({ a: 1 })).toEqual({ 1: "a" }); +}); + +test("inverts an object with multiple key-value pairs", () => { + expect(invert({ a: 1, b: 2 })).toEqual({ + 1: "a", + 2: "b", + }); +}); + +test("returns empty object when given an empty object", () => { + expect(invert({})).toEqual({}); +}); + +test("handles non-string values as keys in the inverted object", () => { + expect(invert({ a: 1, b: true, c: null })).toEqual({ + 1: "a", + true: "b", + null: "c", + }); +}); From 4c3daf61d09f23c044147eda012666ee0b3dfe74 Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Fri, 27 Mar 2026 13:29:40 +0200 Subject: [PATCH 15/24] Revert to main --- Sprint-1/fix/median.js | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/Sprint-1/fix/median.js b/Sprint-1/fix/median.js index f7d2fd653..b22590bc6 100644 --- a/Sprint-1/fix/median.js +++ b/Sprint-1/fix/median.js @@ -6,21 +6,9 @@ // or 'list' has mixed values (the function is expected to sort only numbers). function calculateMedian(list) { - // Filter out non-numeric values and sort the remaining numbers - const numbers = list - .filter((x) => typeof x === "number" && !isNaN(x)) - .sort((a, b) => a - b); - - if (numbers.length === 0) { - return null; - } - - const mid = Math.floor(numbers.length / 2); - if (numbers.length % 2 === 0) { - return (numbers[mid - 1] + numbers[mid]) / 2; - } else { - return numbers[mid]; - } + const middleIndex = Math.floor(list.length / 2); + const median = list.splice(middleIndex, 1)[0]; + return median; } module.exports = calculateMedian; From 1b5a7e816fa4cbdf1c20cef1a6d9413858b813d5 Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Fri, 27 Mar 2026 14:01:50 +0200 Subject: [PATCH 16/24] removed the package.json --- package.json | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 package.json diff --git a/package.json b/package.json deleted file mode 100644 index 2efd299e9..000000000 --- a/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "scripts": { - "test": "jest" - }, - "devDependencies": { - "jest": "^30.3.0" - } -} From 1f43925d359dafc22d499da5edb940702f2e0709 Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Sat, 28 Mar 2026 19:35:45 +0200 Subject: [PATCH 17/24] Fix contains to return false for non-object inputs --- Sprint-2/implement/contains.js | 4 +- print-2q | 327 +++++++++++++++++++++++++++++++++ 2 files changed, 330 insertions(+), 1 deletion(-) create mode 100644 print-2q diff --git a/Sprint-2/implement/contains.js b/Sprint-2/implement/contains.js index 10b94ea28..e2ae1892d 100644 --- a/Sprint-2/implement/contains.js +++ b/Sprint-2/implement/contains.js @@ -1,5 +1,7 @@ function contains(obj, key) { - if (!obj) return false; + if (typeof obj !== "object" || obj === null || Array.isArray(obj)) { + throw new TypeError("First argument must be an object"); + } return Object.prototype.hasOwnProperty.call(obj, key); } diff --git a/print-2q b/print-2q new file mode 100644 index 000000000..8fb524936 --- /dev/null +++ b/print-2q @@ -0,0 +1,327 @@ + + SSUUMMMMAARRYY OOFF LLEESSSS CCOOMMMMAANNDDSS + + Commands marked with * may be preceded by a number, _N. + Notes in parentheses indicate the behavior if _N is given. + A key preceded by a caret indicates the Ctrl key; thus ^K is ctrl-K. + + h H Display this help. + q :q Q :Q ZZ Exit. + --------------------------------------------------------------------------- + + MMOOVVIINNGG + + e ^E j ^N CR * Forward one line (or _N lines). + y ^Y k ^K ^P * Backward one line (or _N lines). + ESC-j * Forward one file line (or _N file lines). + ESC-k * Backward one file line (or _N file lines). + f ^F ^V SPACE * Forward one window (or _N lines). + b ^B ESC-v * Backward one window (or _N lines). + z * Forward one window (and set window to _N). + w * Backward one window (and set window to _N). + ESC-SPACE * Forward one window, but don't stop at end-of-file. + ESC-b * Backward one window, but don't stop at beginning-of-file. + d ^D * Forward one half-window (and set half-window to _N). + u ^U * Backward one half-window (and set half-window to _N). + ESC-) RightArrow * Right one half screen width (or _N positions). + ESC-( LeftArrow * Left one half screen width (or _N positions). + ESC-} ^RightArrow Right to last column displayed. + ESC-{ ^LeftArrow Left to first column. + F Forward forever; like "tail -f". + ESC-F Like F but stop when search pattern is found. + ESC-f Like F but ring the bell when search pattern is found. + r ^R ^L Repaint screen. + R Repaint screen, discarding buffered input. + --------------------------------------------------- + Default "window" is the screen height. + Default "half-window" is half of the screen height. + --------------------------------------------------------------------------- + + SSEEAARRCCHHIINNGG + + /_p_a_t_t_e_r_n * Search forward for (_N-th) matching line. + ?_p_a_t_t_e_r_n * Search backward for (_N-th) matching line. + n * Repeat previous search (for _N-th occurrence). + N * Repeat previous search in reverse direction. + ESC-n * Repeat previous search, spanning files. + ESC-N * Repeat previous search, reverse dir. & spanning files. + ^O^N ^On * Search forward for (_N-th) OSC8 hyperlink. + ^O^P ^Op * Search backward for (_N-th) OSC8 hyperlink. + ^O^L ^Ol Jump to the currently selected OSC8 hyperlink. + ESC-u Undo (toggle) search highlighting. + ESC-U Clear search highlighting. + &_p_a_t_t_e_r_n * Display only matching lines. + --------------------------------------------------- + Search is case-sensitive unless changed with -i or -I. + A search pattern may begin with one or more of: + ^N or ! Search for NON-matching lines. + ^E or * Search multiple files (pass thru END OF FILE). + ^F or @ Start search at FIRST file (for /) or last file (for ?). + ^K Highlight matches, but don't move (KEEP position). + ^R Don't use REGULAR EXPRESSIONS. + ^S _n Search for match in _n-th parenthesized subpattern. + ^W WRAP search if no match found. + ^L Enter next character literally into pattern. + --------------------------------------------------------------------------- + + JJUUMMPPIINNGG + + g < ESC-< * Go to first line in file (or line _N). + G > ESC-> * Go to last line in file (or line _N). + p % * Go to beginning of file (or _N percent into file). + t * Go to the (_N-th) next tag. + T * Go to the (_N-th) previous tag. + { ( [ * Find close bracket } ) ]. + } ) ] * Find open bracket { ( [. + ESC-^F _<_c_1_> _<_c_2_> * Find close bracket _<_c_2_>. + ESC-^B _<_c_1_> _<_c_2_> * Find open bracket _<_c_1_>. + --------------------------------------------------- + Each "find close bracket" command goes forward to the close bracket + matching the (_N-th) open bracket in the top line. + Each "find open bracket" command goes backward to the open bracket + matching the (_N-th) close bracket in the bottom line. + + m_<_l_e_t_t_e_r_> Mark the current top line with . + M_<_l_e_t_t_e_r_> Mark the current bottom line with . + '_<_l_e_t_t_e_r_> Go to a previously marked position. + '' Go to the previous position. + ^X^X Same as '. + ESC-m_<_l_e_t_t_e_r_> Clear a mark. + --------------------------------------------------- + A mark is any upper-case or lower-case letter. + Certain marks are predefined: + ^ means beginning of the file + $ means end of the file + --------------------------------------------------------------------------- + + CCHHAANNGGIINNGG FFIILLEESS + + :e [_f_i_l_e] Examine a new file. + ^X^V Same as :e. + :n * Examine the (_N-th) next file from the command line. + :p * Examine the (_N-th) previous file from the command line. + :x * Examine the first (or _N-th) file from the command line. + ^O^O Open the currently selected OSC8 hyperlink. + :d Delete the current file from the command line list. + = ^G :f Print current file name. + --------------------------------------------------------------------------- + + MMIISSCCEELLLLAANNEEOOUUSS CCOOMMMMAANNDDSS + + -_<_f_l_a_g_> Toggle a command line option [see OPTIONS below]. + --_<_n_a_m_e_> Toggle a command line option, by name. + __<_f_l_a_g_> Display the setting of a command line option. + ___<_n_a_m_e_> Display the setting of an option, by name. + +_c_m_d Execute the less cmd each time a new file is examined. + + !_c_o_m_m_a_n_d Execute the shell command with $SHELL. + #_c_o_m_m_a_n_d Execute the shell command, expanded like a prompt. + |XX_c_o_m_m_a_n_d Pipe file between current pos & mark XX to shell command. + s _f_i_l_e Save input to a file. + v Edit the current file with $VISUAL or $EDITOR. + V Print version number of "less". + --------------------------------------------------------------------------- + + OOPPTTIIOONNSS + + Most options may be changed either on the command line, + or from within less by using the - or -- command. + Options may be given in one of two forms: either a single + character preceded by a -, or a name preceded by --. + + -? ........ --help + Display help (from command line). + -a ........ --search-skip-screen + Search skips current screen. + -A ........ --SEARCH-SKIP-SCREEN + Search starts just after target line. + -b [_N] .... --buffers=[_N] + Number of buffers. + -B ........ --auto-buffers + Don't automatically allocate buffers for pipes. + -c ........ --clear-screen + Repaint by clearing rather than scrolling. + -d ........ --dumb + Dumb terminal. + -D xx_c_o_l_o_r . --color=xx_c_o_l_o_r + Set screen colors. + -e -E .... --quit-at-eof --QUIT-AT-EOF + Quit at end of file. + -f ........ --force + Force open non-regular files. + -F ........ --quit-if-one-screen + Quit if entire file fits on first screen. + -g ........ --hilite-search + Highlight only last match for searches. + -G ........ --HILITE-SEARCH + Don't highlight any matches for searches. + -h [_N] .... --max-back-scroll=[_N] + Backward scroll limit. + -i ........ --ignore-case + Ignore case in searches that do not contain uppercase. + -I ........ --IGNORE-CASE + Ignore case in all searches. + -j [_N] .... --jump-target=[_N] + Screen position of target lines. + -J ........ --status-column + Display a status column at left edge of screen. + -k _f_i_l_e ... --lesskey-file=_f_i_l_e + Use a compiled lesskey file. + -K ........ --quit-on-intr + Exit less in response to ctrl-C. + -L ........ --no-lessopen + Ignore the LESSOPEN environment variable. + -m -M .... --long-prompt --LONG-PROMPT + Set prompt style. + -n ......... --line-numbers + Suppress line numbers in prompts and messages. + -N ......... --LINE-NUMBERS + Display line number at start of each line. + -o [_f_i_l_e] .. --log-file=[_f_i_l_e] + Copy to log file (standard input only). + -O [_f_i_l_e] .. --LOG-FILE=[_f_i_l_e] + Copy to log file (unconditionally overwrite). + -p _p_a_t_t_e_r_n . --pattern=[_p_a_t_t_e_r_n] + Start at pattern (from command line). + -P [_p_r_o_m_p_t] --prompt=[_p_r_o_m_p_t] + Define new prompt. + -q -Q .... --quiet --QUIET --silent --SILENT + Quiet the terminal bell. + -r -R .... --raw-control-chars --RAW-CONTROL-CHARS + Output "raw" control characters. + -s ........ --squeeze-blank-lines + Squeeze multiple blank lines. + -S ........ --chop-long-lines + Chop (truncate) long lines rather than wrapping. + -t _t_a_g .... --tag=[_t_a_g] + Find a tag. + -T [_t_a_g_s_f_i_l_e] --tag-file=[_t_a_g_s_f_i_l_e] + Use an alternate tags file. + -u -U .... --underline-special --UNDERLINE-SPECIAL + Change handling of backspaces, tabs and carriage returns. + -V ........ --version + Display the version number of "less". + -w ........ --hilite-unread + Highlight first new line after forward-screen. + -W ........ --HILITE-UNREAD + Highlight first new line after any forward movement. + -x [_N[,...]] --tabs=[_N[,...]] + Set tab stops. + -X ........ --no-init + Don't use termcap init/deinit strings. + -y [_N] .... --max-forw-scroll=[_N] + Forward scroll limit. + -z [_N] .... --window=[_N] + Set size of window. + -" [_c[_c]] . --quotes=[_c[_c]] + Set shell quote characters. + -~ ........ --tilde + Don't display tildes after end of file. + -# [_N] .... --shift=[_N] + Set horizontal scroll amount (0 = one half screen width). + + --autosave=[_m_/_!_*] + Actions which cause the history file to be saved. + --exit-follow-on-close + Exit F command on a pipe when writer closes pipe. + --file-size + Automatically determine the size of the input file. + --follow-name + The F command changes files if the input file is renamed. + --form-feed + Stop scrolling when a form feed character is reached. + --header=[_L[,_C[,_N]]] + Use _L lines (starting at line _N) and _C columns as headers. + --incsearch + Search file as each pattern character is typed in. + --intr=[_C] + Use _C instead of ^X to interrupt a read. + --lesskey-context=_t_e_x_t + Use lesskey source file contents. + --lesskey-src=_f_i_l_e + Use a lesskey source file. + --line-num-width=[_N] + Set the width of the -N line number field to _N characters. + --match-shift=[_N] + Show at least _N characters to the left of a search match. + --modelines=[_N] + Read _N lines from the input file and look for vim modelines. + --mouse + Enable mouse input. + --no-edit-warn + Don't warn when using v command on a file opened via LESSOPEN. + --no-keypad + Don't send termcap keypad init/deinit strings. + --no-histdups + Remove duplicates from command history. + --no-number-headers + Don't give line numbers to header lines. + --no-paste + Ignore pasted input. + --no-search-header-lines + Searches do not include header lines. + --no-search-header-columns + Searches do not include header columns. + --no-search-headers + Searches do not include header lines or columns. + --no-vbell + Disable the terminal's visual bell. + --redraw-on-quit + Redraw final screen when quitting. + --rscroll=[_C] + Set the character used to mark truncated lines. + --save-marks + Retain marks across invocations of less. + --search-options=[EFKNRW-] + Set default options for every search. + --show-preproc-errors + Display a message if preprocessor exits with an error status. + --proc-backspace + Process backspaces for bold/underline. + --PROC-BACKSPACE + Treat backspaces as control characters. + --proc-return + Delete carriage returns before newline. + --PROC-RETURN + Treat carriage returns as control characters. + --proc-tab + Expand tabs to spaces. + --PROC-TAB + Treat tabs as control characters. + --status-col-width=[_N] + Set the width of the -J status column to _N characters. + --status-line + Highlight or color the entire line containing a mark. + --use-backslash + Subsequent options use backslash as escape char. + --use-color + Enables colored text. + --wheel-lines=[_N] + Each click of the mouse wheel moves _N lines. + --wordwrap + Wrap lines at spaces. + + + --------------------------------------------------------------------------- + + LLIINNEE EEDDIITTIINNGG + + These keys can be used to edit text being entered + on the "command line" at the bottom of the screen. + + RightArrow ..................... ESC-l ... Move cursor right one character. + LeftArrow ...................... ESC-h ... Move cursor left one character. + ctrl-RightArrow ESC-RightArrow ESC-w ... Move cursor right one word. + ctrl-LeftArrow ESC-LeftArrow ESC-b ... Move cursor left one word. + HOME ........................... ESC-0 ... Move cursor to start of line. + END ............................ ESC-$ ... Move cursor to end of line. + BACKSPACE ................................ Delete char to left of cursor. + DELETE ......................... ESC-x ... Delete char under cursor. + ctrl-BACKSPACE ESC-BACKSPACE ........... Delete word to left of cursor. + ctrl-DELETE .... ESC-DELETE .... ESC-X ... Delete word under cursor. + ctrl-U ......... ESC (MS-DOS only) ....... Delete entire line. + UpArrow ........................ ESC-k ... Retrieve previous command line. + DownArrow ...................... ESC-j ... Retrieve next command line. + TAB ...................................... Complete filename & cycle. + SHIFT-TAB ...................... ESC-TAB Complete filename & reverse cycle. + ctrl-L ................................... Complete filename, list all. From 84d5a4e111fa38deba169dd131d37c5b1a788a90 Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Sat, 28 Mar 2026 19:45:48 +0200 Subject: [PATCH 18/24] Use Object.hasOwn and handle non-object inputs correctly --- Sprint-2/implement/contains.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-2/implement/contains.js b/Sprint-2/implement/contains.js index e2ae1892d..0c82e585f 100644 --- a/Sprint-2/implement/contains.js +++ b/Sprint-2/implement/contains.js @@ -1,9 +1,9 @@ function contains(obj, key) { if (typeof obj !== "object" || obj === null || Array.isArray(obj)) { - throw new TypeError("First argument must be an object"); + return false; } - return Object.prototype.hasOwnProperty.call(obj, key); + return Object.hasOwn(obj, key); } module.exports = contains; From b996f9f78156ecde9216f4b0edb1ce96a058f9eb Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Sat, 28 Mar 2026 19:55:22 +0200 Subject: [PATCH 19/24] Improve array test to ensure contains returns false for valid array keys --- Sprint-2/implement/contains.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/implement/contains.test.js b/Sprint-2/implement/contains.test.js index b8008fb38..67b8961cc 100644 --- a/Sprint-2/implement/contains.test.js +++ b/Sprint-2/implement/contains.test.js @@ -25,7 +25,7 @@ test("returns false for a non-existent property", () => { // When passed to contains // Then it should return false or throw an error test("returns false for an array", () => { - expect(contains([], "a")).toBe(false); + expect(contains([1, 2, 3], 0)).toBe(false); }); // Given invalid parameters like null From 92779c2ce6ce0c9598fe2275437868bb644f98f8 Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Sat, 28 Mar 2026 20:07:20 +0200 Subject: [PATCH 20/24] Handle empty query string pairs correctly --- Sprint-2/implement/querystring.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/implement/querystring.js b/Sprint-2/implement/querystring.js index 9e8fdff5d..7a9722084 100644 --- a/Sprint-2/implement/querystring.js +++ b/Sprint-2/implement/querystring.js @@ -5,7 +5,7 @@ function parseQueryString(queryString) { const pairs = queryString.split("&"); pairs.forEach((pair) => { - if (!pair) return; + if (pair === "") return; const index = pair.indexOf("="); From c86466560c9e6b177042dd6e939f80f66d777928 Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Sat, 28 Mar 2026 22:09:16 +0200 Subject: [PATCH 21/24] Add invert.test.js and move tests from invert.js --- Sprint-2/implement/invert.test.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Sprint-2/implement/invert.test.js diff --git a/Sprint-2/implement/invert.test.js b/Sprint-2/implement/invert.test.js new file mode 100644 index 000000000..bab674c82 --- /dev/null +++ b/Sprint-2/implement/invert.test.js @@ -0,0 +1,24 @@ +const invert = require("./invert"); + +test("inverts a simple object", () => { + expect(invert({ a: 1 })).toEqual({ 1: "a" }); +}); + +test("inverts an object with multiple key-value pairs", () => { + expect(invert({ a: 1, b: 2 })).toEqual({ + 1: "a", + 2: "b", + }); +}); + +test("returns empty object when given an empty object", () => { + expect(invert({})).toEqual({}); +}); + +test("handles non-string values as keys in the inverted object", () => { + expect(invert({ a: 1, b: true, c: null })).toEqual({ + 1: "a", + true: "b", + null: "c", + }); +}); From c547fdcb32a5c2757ebe7227374f51565219c6fc Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Sat, 28 Mar 2026 22:14:00 +0200 Subject: [PATCH 22/24] Separate invert tests from implementation into invert.test.js --- Sprint-2/interpret/invert.js | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/Sprint-2/interpret/invert.js b/Sprint-2/interpret/invert.js index 692539dbc..782c12f53 100644 --- a/Sprint-2/interpret/invert.js +++ b/Sprint-2/interpret/invert.js @@ -27,27 +27,3 @@ function invert(obj) { // d) Explain why the current return value is different from the target output // e) Fix the implementation of invert (and write tests to prove it's fixed!) -const invert = require("./invert"); - -test("inverts a simple object", () => { - expect(invert({ a: 1 })).toEqual({ 1: "a" }); -}); - -test("inverts an object with multiple key-value pairs", () => { - expect(invert({ a: 1, b: 2 })).toEqual({ - 1: "a", - 2: "b", - }); -}); - -test("returns empty object when given an empty object", () => { - expect(invert({})).toEqual({}); -}); - -test("handles non-string values as keys in the inverted object", () => { - expect(invert({ a: 1, b: true, c: null })).toEqual({ - 1: "a", - true: "b", - null: "c", - }); -}); From cdfdd7cdb4e23be0933fb7e97dc2d3d0518a26fd Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Sat, 28 Mar 2026 23:22:02 +0200 Subject: [PATCH 23/24] Co-authored-by: Isaac Abodunrin Move invert tests from invert.js to invert.test.js --- Sprint-2/interpret/invert.js | 1 + Sprint-2/{implement => interpret}/invert.test.js | 0 2 files changed, 1 insertion(+) rename Sprint-2/{implement => interpret}/invert.test.js (100%) diff --git a/Sprint-2/interpret/invert.js b/Sprint-2/interpret/invert.js index 782c12f53..b1525b9a5 100644 --- a/Sprint-2/interpret/invert.js +++ b/Sprint-2/interpret/invert.js @@ -15,6 +15,7 @@ function invert(obj) { return invertedObj; } +module.exports = invert; // a) What is the current return value when invert is called with { a : 1 } diff --git a/Sprint-2/implement/invert.test.js b/Sprint-2/interpret/invert.test.js similarity index 100% rename from Sprint-2/implement/invert.test.js rename to Sprint-2/interpret/invert.test.js From 78467970c1e11e42c0e7c63496c7eff83798f1e7 Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Sat, 28 Mar 2026 23:46:06 +0200 Subject: [PATCH 24/24] deleted an unnecessary file --- print-2q | 327 ------------------------------------------------------- 1 file changed, 327 deletions(-) delete mode 100644 print-2q diff --git a/print-2q b/print-2q deleted file mode 100644 index 8fb524936..000000000 --- a/print-2q +++ /dev/null @@ -1,327 +0,0 @@ - - SSUUMMMMAARRYY OOFF LLEESSSS CCOOMMMMAANNDDSS - - Commands marked with * may be preceded by a number, _N. - Notes in parentheses indicate the behavior if _N is given. - A key preceded by a caret indicates the Ctrl key; thus ^K is ctrl-K. - - h H Display this help. - q :q Q :Q ZZ Exit. - --------------------------------------------------------------------------- - - MMOOVVIINNGG - - e ^E j ^N CR * Forward one line (or _N lines). - y ^Y k ^K ^P * Backward one line (or _N lines). - ESC-j * Forward one file line (or _N file lines). - ESC-k * Backward one file line (or _N file lines). - f ^F ^V SPACE * Forward one window (or _N lines). - b ^B ESC-v * Backward one window (or _N lines). - z * Forward one window (and set window to _N). - w * Backward one window (and set window to _N). - ESC-SPACE * Forward one window, but don't stop at end-of-file. - ESC-b * Backward one window, but don't stop at beginning-of-file. - d ^D * Forward one half-window (and set half-window to _N). - u ^U * Backward one half-window (and set half-window to _N). - ESC-) RightArrow * Right one half screen width (or _N positions). - ESC-( LeftArrow * Left one half screen width (or _N positions). - ESC-} ^RightArrow Right to last column displayed. - ESC-{ ^LeftArrow Left to first column. - F Forward forever; like "tail -f". - ESC-F Like F but stop when search pattern is found. - ESC-f Like F but ring the bell when search pattern is found. - r ^R ^L Repaint screen. - R Repaint screen, discarding buffered input. - --------------------------------------------------- - Default "window" is the screen height. - Default "half-window" is half of the screen height. - --------------------------------------------------------------------------- - - SSEEAARRCCHHIINNGG - - /_p_a_t_t_e_r_n * Search forward for (_N-th) matching line. - ?_p_a_t_t_e_r_n * Search backward for (_N-th) matching line. - n * Repeat previous search (for _N-th occurrence). - N * Repeat previous search in reverse direction. - ESC-n * Repeat previous search, spanning files. - ESC-N * Repeat previous search, reverse dir. & spanning files. - ^O^N ^On * Search forward for (_N-th) OSC8 hyperlink. - ^O^P ^Op * Search backward for (_N-th) OSC8 hyperlink. - ^O^L ^Ol Jump to the currently selected OSC8 hyperlink. - ESC-u Undo (toggle) search highlighting. - ESC-U Clear search highlighting. - &_p_a_t_t_e_r_n * Display only matching lines. - --------------------------------------------------- - Search is case-sensitive unless changed with -i or -I. - A search pattern may begin with one or more of: - ^N or ! Search for NON-matching lines. - ^E or * Search multiple files (pass thru END OF FILE). - ^F or @ Start search at FIRST file (for /) or last file (for ?). - ^K Highlight matches, but don't move (KEEP position). - ^R Don't use REGULAR EXPRESSIONS. - ^S _n Search for match in _n-th parenthesized subpattern. - ^W WRAP search if no match found. - ^L Enter next character literally into pattern. - --------------------------------------------------------------------------- - - JJUUMMPPIINNGG - - g < ESC-< * Go to first line in file (or line _N). - G > ESC-> * Go to last line in file (or line _N). - p % * Go to beginning of file (or _N percent into file). - t * Go to the (_N-th) next tag. - T * Go to the (_N-th) previous tag. - { ( [ * Find close bracket } ) ]. - } ) ] * Find open bracket { ( [. - ESC-^F _<_c_1_> _<_c_2_> * Find close bracket _<_c_2_>. - ESC-^B _<_c_1_> _<_c_2_> * Find open bracket _<_c_1_>. - --------------------------------------------------- - Each "find close bracket" command goes forward to the close bracket - matching the (_N-th) open bracket in the top line. - Each "find open bracket" command goes backward to the open bracket - matching the (_N-th) close bracket in the bottom line. - - m_<_l_e_t_t_e_r_> Mark the current top line with . - M_<_l_e_t_t_e_r_> Mark the current bottom line with . - '_<_l_e_t_t_e_r_> Go to a previously marked position. - '' Go to the previous position. - ^X^X Same as '. - ESC-m_<_l_e_t_t_e_r_> Clear a mark. - --------------------------------------------------- - A mark is any upper-case or lower-case letter. - Certain marks are predefined: - ^ means beginning of the file - $ means end of the file - --------------------------------------------------------------------------- - - CCHHAANNGGIINNGG FFIILLEESS - - :e [_f_i_l_e] Examine a new file. - ^X^V Same as :e. - :n * Examine the (_N-th) next file from the command line. - :p * Examine the (_N-th) previous file from the command line. - :x * Examine the first (or _N-th) file from the command line. - ^O^O Open the currently selected OSC8 hyperlink. - :d Delete the current file from the command line list. - = ^G :f Print current file name. - --------------------------------------------------------------------------- - - MMIISSCCEELLLLAANNEEOOUUSS CCOOMMMMAANNDDSS - - -_<_f_l_a_g_> Toggle a command line option [see OPTIONS below]. - --_<_n_a_m_e_> Toggle a command line option, by name. - __<_f_l_a_g_> Display the setting of a command line option. - ___<_n_a_m_e_> Display the setting of an option, by name. - +_c_m_d Execute the less cmd each time a new file is examined. - - !_c_o_m_m_a_n_d Execute the shell command with $SHELL. - #_c_o_m_m_a_n_d Execute the shell command, expanded like a prompt. - |XX_c_o_m_m_a_n_d Pipe file between current pos & mark XX to shell command. - s _f_i_l_e Save input to a file. - v Edit the current file with $VISUAL or $EDITOR. - V Print version number of "less". - --------------------------------------------------------------------------- - - OOPPTTIIOONNSS - - Most options may be changed either on the command line, - or from within less by using the - or -- command. - Options may be given in one of two forms: either a single - character preceded by a -, or a name preceded by --. - - -? ........ --help - Display help (from command line). - -a ........ --search-skip-screen - Search skips current screen. - -A ........ --SEARCH-SKIP-SCREEN - Search starts just after target line. - -b [_N] .... --buffers=[_N] - Number of buffers. - -B ........ --auto-buffers - Don't automatically allocate buffers for pipes. - -c ........ --clear-screen - Repaint by clearing rather than scrolling. - -d ........ --dumb - Dumb terminal. - -D xx_c_o_l_o_r . --color=xx_c_o_l_o_r - Set screen colors. - -e -E .... --quit-at-eof --QUIT-AT-EOF - Quit at end of file. - -f ........ --force - Force open non-regular files. - -F ........ --quit-if-one-screen - Quit if entire file fits on first screen. - -g ........ --hilite-search - Highlight only last match for searches. - -G ........ --HILITE-SEARCH - Don't highlight any matches for searches. - -h [_N] .... --max-back-scroll=[_N] - Backward scroll limit. - -i ........ --ignore-case - Ignore case in searches that do not contain uppercase. - -I ........ --IGNORE-CASE - Ignore case in all searches. - -j [_N] .... --jump-target=[_N] - Screen position of target lines. - -J ........ --status-column - Display a status column at left edge of screen. - -k _f_i_l_e ... --lesskey-file=_f_i_l_e - Use a compiled lesskey file. - -K ........ --quit-on-intr - Exit less in response to ctrl-C. - -L ........ --no-lessopen - Ignore the LESSOPEN environment variable. - -m -M .... --long-prompt --LONG-PROMPT - Set prompt style. - -n ......... --line-numbers - Suppress line numbers in prompts and messages. - -N ......... --LINE-NUMBERS - Display line number at start of each line. - -o [_f_i_l_e] .. --log-file=[_f_i_l_e] - Copy to log file (standard input only). - -O [_f_i_l_e] .. --LOG-FILE=[_f_i_l_e] - Copy to log file (unconditionally overwrite). - -p _p_a_t_t_e_r_n . --pattern=[_p_a_t_t_e_r_n] - Start at pattern (from command line). - -P [_p_r_o_m_p_t] --prompt=[_p_r_o_m_p_t] - Define new prompt. - -q -Q .... --quiet --QUIET --silent --SILENT - Quiet the terminal bell. - -r -R .... --raw-control-chars --RAW-CONTROL-CHARS - Output "raw" control characters. - -s ........ --squeeze-blank-lines - Squeeze multiple blank lines. - -S ........ --chop-long-lines - Chop (truncate) long lines rather than wrapping. - -t _t_a_g .... --tag=[_t_a_g] - Find a tag. - -T [_t_a_g_s_f_i_l_e] --tag-file=[_t_a_g_s_f_i_l_e] - Use an alternate tags file. - -u -U .... --underline-special --UNDERLINE-SPECIAL - Change handling of backspaces, tabs and carriage returns. - -V ........ --version - Display the version number of "less". - -w ........ --hilite-unread - Highlight first new line after forward-screen. - -W ........ --HILITE-UNREAD - Highlight first new line after any forward movement. - -x [_N[,...]] --tabs=[_N[,...]] - Set tab stops. - -X ........ --no-init - Don't use termcap init/deinit strings. - -y [_N] .... --max-forw-scroll=[_N] - Forward scroll limit. - -z [_N] .... --window=[_N] - Set size of window. - -" [_c[_c]] . --quotes=[_c[_c]] - Set shell quote characters. - -~ ........ --tilde - Don't display tildes after end of file. - -# [_N] .... --shift=[_N] - Set horizontal scroll amount (0 = one half screen width). - - --autosave=[_m_/_!_*] - Actions which cause the history file to be saved. - --exit-follow-on-close - Exit F command on a pipe when writer closes pipe. - --file-size - Automatically determine the size of the input file. - --follow-name - The F command changes files if the input file is renamed. - --form-feed - Stop scrolling when a form feed character is reached. - --header=[_L[,_C[,_N]]] - Use _L lines (starting at line _N) and _C columns as headers. - --incsearch - Search file as each pattern character is typed in. - --intr=[_C] - Use _C instead of ^X to interrupt a read. - --lesskey-context=_t_e_x_t - Use lesskey source file contents. - --lesskey-src=_f_i_l_e - Use a lesskey source file. - --line-num-width=[_N] - Set the width of the -N line number field to _N characters. - --match-shift=[_N] - Show at least _N characters to the left of a search match. - --modelines=[_N] - Read _N lines from the input file and look for vim modelines. - --mouse - Enable mouse input. - --no-edit-warn - Don't warn when using v command on a file opened via LESSOPEN. - --no-keypad - Don't send termcap keypad init/deinit strings. - --no-histdups - Remove duplicates from command history. - --no-number-headers - Don't give line numbers to header lines. - --no-paste - Ignore pasted input. - --no-search-header-lines - Searches do not include header lines. - --no-search-header-columns - Searches do not include header columns. - --no-search-headers - Searches do not include header lines or columns. - --no-vbell - Disable the terminal's visual bell. - --redraw-on-quit - Redraw final screen when quitting. - --rscroll=[_C] - Set the character used to mark truncated lines. - --save-marks - Retain marks across invocations of less. - --search-options=[EFKNRW-] - Set default options for every search. - --show-preproc-errors - Display a message if preprocessor exits with an error status. - --proc-backspace - Process backspaces for bold/underline. - --PROC-BACKSPACE - Treat backspaces as control characters. - --proc-return - Delete carriage returns before newline. - --PROC-RETURN - Treat carriage returns as control characters. - --proc-tab - Expand tabs to spaces. - --PROC-TAB - Treat tabs as control characters. - --status-col-width=[_N] - Set the width of the -J status column to _N characters. - --status-line - Highlight or color the entire line containing a mark. - --use-backslash - Subsequent options use backslash as escape char. - --use-color - Enables colored text. - --wheel-lines=[_N] - Each click of the mouse wheel moves _N lines. - --wordwrap - Wrap lines at spaces. - - - --------------------------------------------------------------------------- - - LLIINNEE EEDDIITTIINNGG - - These keys can be used to edit text being entered - on the "command line" at the bottom of the screen. - - RightArrow ..................... ESC-l ... Move cursor right one character. - LeftArrow ...................... ESC-h ... Move cursor left one character. - ctrl-RightArrow ESC-RightArrow ESC-w ... Move cursor right one word. - ctrl-LeftArrow ESC-LeftArrow ESC-b ... Move cursor left one word. - HOME ........................... ESC-0 ... Move cursor to start of line. - END ............................ ESC-$ ... Move cursor to end of line. - BACKSPACE ................................ Delete char to left of cursor. - DELETE ......................... ESC-x ... Delete char under cursor. - ctrl-BACKSPACE ESC-BACKSPACE ........... Delete word to left of cursor. - ctrl-DELETE .... ESC-DELETE .... ESC-X ... Delete word under cursor. - ctrl-U ......... ESC (MS-DOS only) ....... Delete entire line. - UpArrow ........................ ESC-k ... Retrieve previous command line. - DownArrow ...................... ESC-j ... Retrieve next command line. - TAB ...................................... Complete filename & cycle. - SHIFT-TAB ...................... ESC-TAB Complete filename & reverse cycle. - ctrl-L ................................... Complete filename, list all.