Geody Labs


# Main Index: Debian Linux Magic Spells Cheat Sheet (one liners, how to, tips and tricks)

# Text Editors

Jed

apt-get install jed jed FILE.txt # Create or edit FILE.txt jed FILE.txt -g LINE # Open FILE.txt for editing, set cursor position at the given LINE jed FILE.txt -s "TEXT" # Open FILE.txt for editing, set cursor position at the first occurrence of the given TEXT

Vim

apt-get install vim vim FILE.txt # Create or edit FILE.txt (cursor on the first line) vim + FILE.txt # Edit FILE.txt and place cursor on the last line vim +N FILE.txt # Edit FILE.txt and place cursor on line N # While Jed is an easy and intuitive text editor, it might happen that it's not available in the system on which you are working. # In this case you'll likely have to use vim instead which is powerful in trained hands but much less intuitive. # This is a list of some basic and useful commands Cursor keys / h, l, j, k : Cursor movement (left, right, down, up) b : Jump to the word on the left w : Jump to the word on the right ( : Jump to the sentence on the left ) : Jump to the sentence on the right ^ / 0 : Jump to the beginning of the line $ / gm : Jump to the end of the line - : Jump to the first non blank character of the previous line + : Jump to the first non blank character of the next line { : Jump to the previous paragraph } : Jump to the next paragraph [[ : Jump to the beginning of the file ]] : Jump to the end of the file [LINE_NUMBER]G / [LINE_NUMBER]gg : Jump to the given LINE NUMBER [VALUE]% : Jump to the specified position of the document [COLOUMN]| : Jump to the specified COLOUMN in the current line [LINE]H : Jump to the given LINE visible in the current window, from the top [LINE]L : Jump to the given LINE visible in the current window, from the bottom M : Jump to the line in the middle of the current window zt : Place current line at the top of the window zz : Place current line at the middle of the window zb : Place current line at the bottom of the window i : Enter Insert mode I : Jump at the beginning of the line and enter Insert mode s : Delete the character under the cursor and enter Insert mode R : Enter Replace mode (Overwrite) ESC : Exit Edit mode (either Insert or Replace (Overwrite)) Commands in Edit mode (^ means CONTROL): ^w : Delete characters from cursor position to the beginning of the current word ^u : Delete characters from cursor position to the beginning of the current line ^t : Add a Tab at the beginning of the current line (Add indentation) ^r : Remove a Tab from the beginning of the current line (Remove indentation) r : Replace a single character at the cursor position o : Create a new empty line below the current one and enter Insert mode O : Create a new empty line above the current one and enter Insert mode gu[CURSOR_KEY] : Change a single character to lowercase in the direction specified with the cursor key gU[CURSOR_KEY] : Change a single character to uppercase in the direction specified with the cursor key x : Remove the character at the cursor (Delete) X : Remove the character before than the cursor (Backspace) D : Delete until the end of the current line dd : Delete the current line J : Join the current line with the next one adding a space inbetween Y / yy : Copy the current line P / p : Paste the line in the clipboard ga : Show the ASCII value of the character at the cursor position /[TEXT] : Search for the given TEXT n : Repeat last search, forward N : Repeat last search, backwards :s/[SEARCH]/[REPLACE]/ : Search and Replace the first occurrence in the current line only, case sensitive :s/[SEARCH]/[REPLACE]/g : Search and Replace every occurrence in the current line only, case sensitive :%s/[SEARCH]/[REPLACE]/g : Search and Replace every occurrence in the whole file, case sensitive :%s/[SEARCH]/[REPLACE]/gI : Search and Replace every occurrence in the whole file, case sensitive :%s/[SEARCH]/[REPLACE]/gi : Search and Replace every occurrence in the whole file, case insensitive :%s/[SEARCH]/[REPLACE]/gic : Search and Replace every occurrence in the whole file, case insensitive, and ask for confirmation :%s/\s\+$// : Remove trailing spaces in the whole file :%s/^\s\+// : Remove leading spaces in the whole file :set number / :set nu : Display line numbers :set nonumber / :set nonu : Turn off line numbers :set number! / :set nu! : Toggle line numbers :set relativenumber : Display line numbers relative to the cursor line :set norelativenumber : Remove line numbers relative to the cursor line :set relativenumber! : Toggle line numbers relative to the cursor line # If number and relativenumber are both enabled the absolute line number will be shown in the cursor line (instead of 0) :set list : Display special characters :set nolist : Hide special characters :set list! : Toggle special characters :set listchars=eol:$,tab:>-,trail:~,nbsp=! : Configure how to show special characters :help listchars : Display help for listchars (quit with :q) :syntax on : Enable syntax :syntax off : Disable syntax :set syntax=[LANGUAGE] : Display syntax for the specified language (example: html, php, whitespace) :w : Save current file :wq / :x / ZZ : Save current file and quit :q : Quit (it only quits if the current file is saved, otherwise returns an error message) :q! : Quit without saving (doesn't ask for confirmation)




Please DONATE to support the development of Free and Open Source Software (PayPal, Credit Card, Bitcoin, Ether)

Page issued on 25-Sep-2022 06:09 GMT
Copyright (c) 2022 Geody - Legal notices: copyright, privacy policy, disclaimer