Thursday, 17 March 2016

vi editor - shortcuts/cheat sheet

vi editor shortcuts, cheat sheet


Invoking vi


Shortcut/commandDescription
vi fileInvoke vi editor on file
vi file1 file2Invoke vi editor on files sequentially
view fileInvoke vi editor on file in read­only mode
vi -R fileInvoke vi editor on file in read­only mode
vi -r fileRecover file and recent edits after system crash
vi + fileOpen file at last line
vi +n fileOpen file at line number n
vi +/patternfile Open file at pattern



Inserting in vi editor


Shortcut/
command
Description
iInsert before cursor
IInsert before line
aAppend after cursor
AAppend after line
oOpen a new line after current line
OOpen a new line before current line
rReplace one character
RReplace many characters
[Ctrl]v charWhile inserting, ignores special meaning of char (e.g., for inserting characters like ESC and CTRL) until ESC is used
[Ctrl]i or tabWhile inserting, inserts one shift width



Changes in inserting mode in vi editor

To delete/revert last inserted word/chars during inserting mode, without leaving insert mode, use these commands.
Shortcut/
command
Description
[Ctrl]h Back /Remove last one character
[Ctrl]w Back one word
[Ctrl]u Back /Remove last Back to beginning of insert



Deleting in vi editor


Shortcut/
command
Description
xDelete character to the right of cursor
nxDeletes n characters starting with current; omitting n deletes current character only
XDelete character to the left of cursor
nXDeletes previous n characters; omitting n deletes previous character only
DDelete to the end of the line
dd or :dDelete current line
:dDelete current line
nddDelete n lines together
:n,mdDeletes lines n through m
dwdelete word
dnwDelete n words
d)Delete to end of sentence
dbDelete previous word
ndbDeletes the previous n words starting with current



Motion/ Moving in vi editor


Shortcut/
command
Description
hMove left
jMove down
kMove up
lMove right
wMove to next word
WMove to next blank delimited word
bMove to the beginning of the word
BMove to the beginning of blank delimted word
eMove to the end of the word
EMove to the end of Blank delimited word
(Move a sentence back
)Move a sentence forward
{Move a paragraph back
}Move a paragraph forward
[[Move a section back
]]Move a section forward
0 or |Move to the begining of the line
n|Moves to the column n in the current line
$Move to the end of the line
1GMove to the first line of the file
GMove to the last line of the file
nGMove to nth line of the file
:nMove to nth line of the file
fcMove forward to c
FcMove back to c
HMove to top of screen
nHMoves to nth line from the top of the screen
MMove to middle of screen
LMove to botton of screen
nLMoves to nth line from the bottom of the screen
%Move to associated ( ), { }, [ ]
[Ctrl]GShows filename, current line number, total lines in file, and % of file location
:.=Display current line number
:=Shows number of lines in file
|Displays tab (^l) backslash (\) backspace (^H) newline ($) bell (^G) formfeed (^L^) of current line



Files, Exit and Save Commands in vi editor


Shortcut/
command
Description
:w fileWrite to file
:wqWrite to file and quit
:w %.newSave current buffer named file as file.new
ZZSame as :wq
:xSave and exit.
:q!Quit without saving changes
:qquit
:e file2Edit other file file2 without leaving vi
:e! file2Discard changes to current file, then edit file2 without leaving vi
:e!Discard all changes since last save
:e#Edit alternate file
:r fileRead file in after line
:r!commandInsert the output from a UNIX command into a file, immediately after the cursor
:nGo to next file
:pGo to previos file



Shell commands in vi editor


Shortcut/
command
Description
:! cmdExecutes shell command cmd; 
!! cmdExecutes shell command cmd, places output in file starting at current line
:!!Executes last shell command
:r! cmdReads and inserts output from cmd
:f fileRenames current file to file
:w !cmdSends currently edited file to cmd as standard input and execute cmd
:cd dirChanges current working directory to dir
:shStarts a sub-shell (CTRL-d returns to editor)
:so fileReads and executes commands in file (file is a shell script)
!}sortSorts from current position to end of paragraph and replaces text with sorted text



Yanking Text/cut copy paste in vi editor


Shortcut/
command
Description
yy or YYank the current line
:yYank the current line
ywYank word to general buffer
“a9ddDelete 9 lines to buffer a
“A9ddDelete 9 lines; Append to buffer a
“apPut text from buffer a after cursor
ppaste yanked clipboard content after cursor
Ppaste yanked clipboard content before cursor
JJoin lines
y$yanks to the end of the line



Changing text in vi editor


Shortcut/
command
Description
CChange to the end of the line
CTextChanges rest of the current line to text until ESC is used
cc or sChange the whole line
sTextSubstitutes text for the current character until ESC is used
xpSwitches character at cursor with following character
cwChange word (Esc)
cwTextChanges current word to text until ESC is used
c$Change to end of line
rcReplace character with c
<< or >>Shifts the line left or right (respectively) by one shift width (a tab)
n<< or n>>Shifts n lines left or right (respectively) by one shift width (a tab)



Markers in vi editor


Shortcut/
command
Description
mcSet marker c on this line
`cGo to beginning of marker c line.
'cGo to first non-blank character of marker c line.
'Return to begining of line containing previous mark
``Return to previous mark or context



Search operations in vi editor


Shortcut/
command
Description
/stringSearch forward for string
?stringSearch back for string
nSearch for next instance of string
NSearch for previous instance of string
fxsearch forward for character x in current line
Fxsearch backward for character x in current line
txsearch forward for character before x in current line
Txsearch backward for character after x in current line
;Repeat previous current­line search
,Repeat previous current­line search in opposite direction
&Repeats last :s command
:set icIgnores case when searching
:set noicPays attention to case when searching
:n,ms/str1/str2/optSearches from n to m for str1; replaces str1 to str2; using opt-opt can be g for global change, c to confirm change (y to acknowledge, to suppress), and p to print changed lines
:g/str/cmdRuns cmd on all lines that contain str
g/str1/s/str2/str3/Finds the line containing str1, replaces str2 with str3
:v/str/cmdExecutes cmd on all lines that do not match str



Replace operations in vi editor

The search and replace function is accomplished with the :s command. It is commonly used in combination with ranges or the :g command
Shortcut/
command
Description
:s/pattern/string/flagsReplace pattern with string according to flags.
gFlag - Replace all occurences of pattern
cFlag - Confirm replaces.
&Repeat last :s command



Regular expressions in vi editor


Shortcut/
command
Description
. (dot)Any single character except newline
*zero or more occurances of any character
[...]Any single character specified in the set
[^...]Any single character not specified in the set
^Anchor - beginning of the line
$Anchor - end of line
\<Anchor - begining of word
\>Anchor - end of word
\(...\)Grouping - usually used to group conditions
\nContents of nth grouping



Ranges in vi editor


Shortcut/
command
Description
:n,mRange - Lines n-m
:.Range - Current line
:$Range - Last line
:'cRange - Marker c
:%Range - All lines in file
:g/pattern/Range - All lines that contain pattern



Parameters in vi editor


Shortcut/
command
Description
:set list Show invisible characters
:set nolist Don’t show invisible characters
:set number Show line numbers
:set nonumber Don’t show line numbers
:set autoindent Indent after carriage return
:set noautoindent Turn off autoindent
:set showmatch Show matching sets of parentheses as they are typed
:set noshowmatch Turn off showmatch
:set showmode Display mode on last line of screen
:set noshowmode Turn off showmode
:set all Show values of all possible parameters



Scrolling in vi editor

To scroll within vi editor, use following commands.
Shortcut/
command
Description
[Ctrl]F Scroll forward one screen
[Ctrl]B Scroll backward one screen
[Ctrl]D Scroll down one­half screen
[Ctrl]U Scroll up one­half screen
[Ctrl]E Show one more line at bottom
Ctrl]Y Show one more line at  top of window
zReposition window: cursor at top
nzMakes the line n the top line on the page
z.Reposition window: cursor in middle
nz.Makes the line n the middle line on the page
z-Reposition window: cursor at bottom
nz-Makes the line n the bottom line on the page



Other operations in vi editor


Shortcut/
command
Description
~Toggle upp and lower case
.Repeat last text-changing command
uUndo last change
UUndo all changes to line



tags: vi editor shortcuts, vi editor cheat sheet, vi editor commands, how to navigate in vi editor

Unix shortcuts

Unix/ Linux ShortCuts


Unix/ Linux Keyboard shortcuts

These commands are case insensitive.

Shortcut/commandDescription
[Ctrl]+BMoves the cursor backward one character.
[Ctrl]+CCancels the currently running command.
[Ctrl]+DLogs out of the current session.
[Ctrl]+FMoves the cursor forward one character.
[Ctrl]+HErase one character. Similar to pressing backspace.
[Ctrl]+PPaste previous line(s).
[Ctrl]+SStops all output on screen (XOFF).
[Ctrl]+QTurns all output stopped on screen back on (XON).
[Ctrl]+UErases the complete line.
[Ctrl]+WDeletes the last word typed. For example, if you typed 'mv file1 file2' this shortcut would delete file2.
[Ctrl]+ZCancels current operation, moves back a directory or takes the current operation and moves it to the background. See bg command for additional information about background
[Ctrl]+EAlternative to End key (or) Move cursor to end of command
[Ctrl]+AAlternative to Home key (or) Move cursor to starting of command



Unix/ Linux Command line shortcuts

These are a few command line shortcuts.
Shortcut/
command
Description
~Moves to the user's home directory.
cd -Move to previously accessed directory
cd !$!$ represents the arguments from your last command
mkdir myfolder{1,2,3}create three folders: myfolder1, myfolder2, and myfolder3.
!!Repeats the line last entered at the shell. See history command for previous commands.
!$Repeats the last argument for the command last used. See history command for previous commands.
resetResets the terminal if terminal screen is not displaying correctly.
shutdown -h nowRemotely or locally shuts the system down.
exitlogout
<Mark or Select text><Enter>Copies the text currently highlighted  or marked
<Mouse Right Click>Paste the text which is currently highlighted somewhere else.
aliasUsing alias, we can create shortcuts for frequently used commands/



tags: Unix shortcuts, Linux keyboard shortcuts,

Remove page title in Blogger

How to remove/hide page title in Google Blogger?


In Google Blogger, by default post title you provided will be shown in your page. This makes us easy to proceed with writing content directly. But when you want to display a different heading on page, it looks odd as showing almost two similar headings.


To do this, you can either hide it from Customize template or html version of template. But sometimes, you will face issues while editing html version. And we may delete few things by mistake. So I feel, its better to do with Custom CSS.


Its very simple to hide the post title in your blogger. Follow below instructions
Note: These changes are not specific to a post, it removes the heading from complete blog.

Step by step instructions to hide title using both Custom CSS & HTML template:

  1. Login to your blogger and navigate to your blog where you would like to hide or remove title.

  2. On left navigation pane, click Template.

Using Custom CSS:

  1. Then click Customize.

  2. Click Advanced and then go to Add CSS.


  3. In Add Custom CSS panel, add the following statement.

  4. h3.post-title{display:none;}

  5. Click 'Apply to Blog' to save.

Using HTML version of template:

  1. Click Edit html.

  2. Expand the following snippet.

  3. <b:skin>....</b:skin>

  4. Then add the following snippet at the end, i.e. just before ]]></b:skin>
    Note: If you already have a custom CSS styles, add it with in style tags, else copy with style tags.

  5. <style> h3.post-title{display:none;} </style>

  6. Now, save template.

That's it. Now check your blog for the changes, whether the title is still shown or not?





tags: How to remove title from Blogger post?, how to hide the post title in Google Blogger?,Removing or hiding post title on my Blog, steps to remove or hide page title from Blogger with images