Creează un cont pentru a te abona la acest blog și a-i urmări articolele pe pagina Lectură.
-
You can save and restore Vim sessions to continue working with the same setup before you had to quit Vim for reasons like switching off the machine, switching to another project, etc.
-
By default, join combines two files based on the first field content (also referred as key).
-
For readability purposes, you can use underscores while declaring large numbers.
-
Often, you just need to change one character.
-
awk has a builtin feature to process input content paragraph wise (by setting RS to an empty string).
-
You might be familiar with negating a character class, for example: >>> import re # remove first two columns >>> re.sub(r'\A([^:]+:){2}', '', 'apple:42:banana:1000:cherry:512') 'banana:1000:cherry:512' # filter all elements not ending with `r` or `t` >>>
-
In Normal mode, you can undo and redo changes using the following commands: u undo last change press u again for further undos U undo latest changes on last edited line Ctrl+r redo a change undone by u U redo changes undone by U See :h 32.3 for details on…
-
You can use wc -L to report the length of the longest line in the input (excluding the newline character of a line). $ echo 'apple' | wc -L 5 # last line not ending with newline won't be a problem $ printf 'apple\nbanana' | wc -L 6 $ cat greeting.txt hi…
-
I've been using Linux for about 15 years.
-
The subprocess module provides plethora of features to execute external commands, capturing output being one of them.
-
In Normal mode, you can use lowercase alphabets a-z to save some content for future use.
-
You can use sort -V for sorting numerical input that is mixed with other characters.
-
So, I was going through GNU bash manual: Shell Parameter Expansion and trying out examples to check if I was understanding the features well.
-
Python supports plenty of string methods that reduces the need for regular expressions.
-
Quoting from What's New In Python 3.11: Atomic grouping ((?
-
In Normal mode, you can join lines using J and gJ commands.
-
awk provides a handy shortcut to process input content paragraph wise.
-
You can merge two dictionaries using the | operator (similar to union of sets).
-
You can use the following commands to change the case of characters: ~ invert the case of the character under the cursor (i.e. lowercase becomes UPPERCASE and vice versa) g~ followed by motion inverts the case of those characters for example: g~e, g~$, g~…
-
The GNU sed command has a couple of handy commands to extract text from the start of input until a matching line is found.
-
I've previously written about events and strategies that led to increased ebook sales during the last quarter of 2021.
-
A lesser known way to create a dictionary is to use the fromkeys() method that accepts an iterable and an optional value (default is None).
-
Vim provides handy commands to match words under (or near to) the cursor.
-
grep supports -m option to specify the maximum number of matching lines in the output. # all input lines containing 'a' $ printf 'goal\nrate\neat\npit\n' | grep 'a' goal rate eat # maximum of 2 matching lines $ printf 'goal\nrate\neat\npit\n' | grep -m2…
-
From copy built-in module: Assignment statements in Python do not copy objects, they create bindings between a target and an object.
-
Find yourself working on a large file?
-
Usually, grep is used for filtering lines based on a regexp pattern.
-
The built-in fileinput module has nice features for file processing, especially handy for multiple files and inplace editing.
-
You're likely to be familiar with commands to scroll through the contents like Ctrl followed by d or f or u or b.
-
The column command is a nifty tool to align input data column wise.
-
Last month I had the wonderful opportunity to be part of PyDev of the Week series organized by Michael Driscoll.
-
Here are a couple of commonly used methods for the built-in random module: choice() method helps you get a random element sample() method helps you get a list of a specific count of random elements >>> import random >>> nums = [1, 4, 5, 2, 51, 3, 6, 22]…
-
In case you haven't yet read this nice post "Get your work recognized: write a brag document" by Julia Evans, please do that first.
-
I posted a coding challenge in the tenth issue of learnbyexample weekly.
-
Autocomplete word Ctrl+p autocomplete word based on matching words in the backward direction Ctrl+n autocomplete word based on matching words in the forward direction If more than one word matches, they are displayed using a popup menu.
-
Similar to a(b+c)d = abd+acd in maths, you get a(b|c)d = abd|acd in regular expressions.
-
The -s option is one of the useful, but lesser known feature of the paste command.
-
In this post, I review Automating Excel with Python by Michael Driscoll.
-
Poster created using Canva While going through :h vim-arguments for my Vim Reference Guide ebook, I came across the -y option: Easy mode.
-
You can chain comparison operators arbitrarily.
-
TL;DR: Started and ended the year well, with a depressing period in the middle.
-
Normal mode >> indent the current line 3>> indent the current line and two lines below (same as 2>j) >k indent the current line and the line above (same as 1>k or >1k) << unindent the current line 5<< unindent the current line and four lines below (same as
-
You can use * to place backups of original files in another directory when using the -i option with GNU sed.
-
I posted a coding challenge in the fifth issue of learnbyexample weekly.
-
In case you haven't yet discovered this awesome f-string feature, you can add = after an expression to get both the expression and the result in the output. >>> num1 = 42 >>> num2 = 7 >>> f'{num1 + num2 = }' 'num1 + num2 = 49' >>> f'{num1 + (num2 * 10) =…
-
Did you know that you can easily increment or decrement a number in Vim?
-
(2023-03-20) Update: This TUI app covers many more exercises compared to the GUI app discussed below.
-
Use grep -c to count the number of input lines containing a given pattern. # number of input lines containing 'a' $ printf 'goal\nrate\neat\npit' | grep -c 'a' 3 # number of input lines containing all the vowels $ grep -icP '^(?
-
Hello!
-
The in membership operator checks if a given value is part of a collection of values.