Commands that I learnt today! (Vim + Linux)
Vim commands that increases your productivity
Table of contents
Later, these days I have realized there should be place or consideration for coding productivity like use of some sorts of tools, that makes your wrist have lesser pain. I found that there are tools like Vim editor extensions that are available for VS code that can be used for boosting productivity while coding. It enhances don't touch your mouse principle which will make you do things faster while coding by enabling your hand to stay at keyboard most of the time.
VIM commands
Vim commands are the core of Vim's functionality, allowing efficient text editing, navigation, and interaction with the editor. Vim commands can be executed in different modes.
Modes in Vim:
Normal Mode: The default mode for navigation and executing commands.
Insert Mode: For inserting and editing text.
Visual Mode: For selecting text visually.
Command-Line Mode: For entering editor commands.
Now, Let's see some commands:
Entering Insert Mode:
i
orI
: Insert mode before/after the cursor.a
orA
: Insert mode after the cursor/end of the line.o
orO
: Open a new line below/above the current line for insertion.
Exiting Insert Mode:
Esc
: Exit from insert mode to normal mode.
Navigation in Normal Mode:
h
,j
,k
,l
: Left, down, up, right (respectively) navigation.w
,b
: Move forward/backward by a word.gg
,G
: Move to the start/end of the document.^
,$
: Move to the start/end of the line.Ctrl + u
,Ctrl + d
: Scroll up/down.
Visual Mode:
v
: Start character-based visual mode.V
: Start line-based visual mode.Ctrl + v
: Start block-based visual mode.
Copying and Pasting:
y
: Yank (copy) selected text.p
: Paste text after the cursor.P
: Paste text before the cursor.
Deleting:
x
: Delete character under the cursor.dd
: Delete the entire line.dw
: Delete word.d$
,d^
: Delete to the end/beginning of the line.
Search and Replace:
/
: Search forward.?
: Search backward.:s/old/new/g
: Replace 'old' with 'new' globally in the line.:%s/old/new/g
: Replace 'old' with 'new' globally in the entire file.
These shortcuts are fundamental in Vim and have significantly sped up my productivity with less interaction with mouse.
Some linux Commands
These are some Linux commands I learnt today:
Pipe: |
In Linux, the pipe |
is a powerful operator used to combine two or more commands together, allowing the output of one command to be used as the input for another. It's used for creating a data flow between commands, enabling you to perform complex operations by chaining multiple commands together.
grep
A grep is a command line utility for searching plain-text for lines that match a regular expressions.
ls | grep names.txt
This command will display any files in the current directory that match the name "names.txt"
.
If you have an idea of the beginning of the file name or its specific pattern, you can use a wildcard character (*
) to match parts of the filename
ls | first_names*
Alternative for grep in Powershell
Get-ChildItem | Where-Object { $_.Name -like '*first*' }
This command will list files in the current directory containing "first" in their names.
rm
rm
stands for "remove." It's used to delete files or directories. For example, to delete a file named "names.txt"
rm names.txt
cp
cp
stands for "copy." It's used to copy files or directories. For example, to copy a file named "source.txt" to a new file "destination.txt":
cp source.txt destination.txt
If you are reading till here thank you for reading. Keep learning! Keep growing!