Skip to content

c4arl0s/VIM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 

Repository files navigation

  1. Basics of VIM
  2. How to insert a string at the beginning of a line
  3. How to cut and paste (ctrl-v or ctrl-V)
  4. How to find a string
  5. how to replace with an / across the string to replace
  6. Repeats the last action
  7. Insert a # character at the beginning of the line
  8. Find an precise string an replace with something
  9. Insert a character or string at the end of a selected line
  10. Insert a consecutive number at the beginning of a selected line
  11. Delete all lines that contains a specific pattern
  12. Make lowercase
  13. Make upercase
  14. Find any String inside parenthesis Ex. (http://...) with empty content ()
  15. Find a particular character in a line using f
  16. Delete only a character
  17. Change inside brackets
  18. Quickly change a word or line
  19. Jump to the place of last Edit
  20. Yank the current line, including the newline character at the end of the new line, yy or Y
  21. Jump to the place before of the last Edit
  22. Yank the current word (no spaces)
  23. Yank the current word (with sorounding spaces)
  24. Yank all contained inside parenthesis ()
  25. Yank all contained inside brackets
  26. Replace the character under the cursor
  27. Enter insert mode, replacing characters rather than inserting
  28. redo
  29. insert mode
  30. remove ... from this line: 1.1 Should Software Engineers Worry About Hardware ......... 23
  31. Find any line starting by any number
  32. Delete the last character the end of the line
  33. Delete the last character at the end of the line if it is a number
  34. Delete the last two characters at the end of the line if they both were a number
  35. Delete the first n characters at the end of a line
  36. Delete empty lines
  37. Delete 1 or more of the preceding spaces at the end of the line
  38. find any header or implementation name file (class.h class.m)
  39. Find a file's name string like class.swift
  40. Find a swift or objective-c method like nameMethod(parameter:)
  41. Using your last course, find any number of digits at the end of a sentence in any line
  42. Enumerate selected lines
  43. Add/insert words to your own word list
  44. Cursor movement VIM
  45. Insert mode - inserting/appending text
  • normal mode [Esc]
  • insert mode [i]
  • replace mode

Selection mode - visual - visual line - visual block

  • command line model

Notations for control + V

^V
Ctrl-V
<C-V>

the interface itself is a programming language

  • ctrl-v
  • drop down with "down arrow" up to the desired line
  • shift + i
  • type what ever you want to insert in the first line
  • type scape
  • then go down with the down arrow, it automatically will appear what you want
  1. take place where your want to start to copy or cut
  2. Type ctrl-v if you want to select a character or type cltr-V if you want to select a full line.
  3. if you type ctrl-v move the cursor where you want to cut/copy. Or move down if you want to copy/cut several lines.
  4. if you want to cut, type Esc then d (delete), if you want to copy, Press Esc then y (yank)
  5. then you move where you want to paste, then press Esq then type p (paste)
  1. Press Esc
  2. type: /
  3. type what you want to find.
  4. Once you find it, press n, to the next ocurrence.
  1. Press Esc
  2. Type :%s/stringTolookFor/stringToReplace/

if the string contains an character like /, then type / to scape it.

example:

:%s/()/(https:\/\/github.com\/c4arl0s\/NavigationAndWorkflows#navigationandworkflows)/
  • Then type enter.
  1. Press ESC
  2. press .
  1. Press Esc
  2. :1,40s/^/# /
  1. Press ESC
  2. :
  3. Type
:%s/\<direccionMemoria\>/memoryDirection/
  1. Select the line or lines. Type ESC, then ctrl-V.
  2. then type: s/$/anyString/

it will looks like this:

:'<,'>s/$/anyString/
let i=1 | '<,'>g/^/ s//\=printf("%d ",i) / | let i+=1
  1. Press Esc
  2. type:
:g/.com/d

g - find it globally .com - pattern .com d - delete

  • another example: Delete all lines that start with // and it is the end of the line
  1. press Esc
  2. type:
:%g/^\/\/$/d
// hola
// 
// como estas
//

output:

// hola
// como estas
  • Select word, line or several words, then:
:gu
  • Select word, line or several words, then:
:gU
:%s/(.*)/()/

In normal mode

type:

fa - finds the first a ahead of the cursor Fa - fins the first a before of the cursor.

type in normal mode:

x

in normal mode:

ci[

cw change word caw ciw cc change an entire line cis change inside sentence

g;
yy
Y

Type again g; so many times required to find the last Edit

g;
yiw

this command exclude white spaces around the word.

yaw

This command include whithe spaces sorounding

yi)
yi]
r{character}
R

then start typing

27. redo

Type Esc, then

u

tyoe Esc, then

ctrl-r

Type . to repeat the last command

  • i - insert before the cursor
  • I - insert at the beginning of the line
  • a - insert after the cursor (aopend)
  • A - insert at the end of the line (append)
  • o - insert a new line below the current line
  • O - insert a new line above the current line
  • ea - insert at the end of the word -

1.1 Should Software Engineers Worry About Hardware .........

remove all dots after the title, including the number

:%s/\..*$//

%s substitude all lines .. scaped dot twice, because 1.1 could be taken. .* all $ up to the end of the line // replace with nothing.

then the output is

1.1 Should Software Engineers Worry About Hardware

/^[0-9]
s/$//
s/.[1-9]$//
s/.[1-9][1-9]$//

replace n with the desired number of characters

:%s/^.\{3}//
:%g/^\s*$/d
%s/\s\+$//
/\<\w*\.h\w*\>/
/\<\w*\.m\w*\>/
/<\w*\.swift\w*>/
/\w*(.*:)/
/ [0-9]\+$//

Example:

1. [this is a test](blablablabla)  Page 1234

It finds the space character and 1234, remember the space, to find this kind of pattern.

Screen Shot 2021-04-16 at 13 45 23

:let i=1 | '<,'>g/^/s//\=i.'. '/ | let i=i+1
zg
h - move cursor left
j - move cursor down
k - move cursor up
l - move cursor right
H - move to top of screen
M - move to middle of screen
L - move to bottom of screen
w - jump forwards to the start of a word
W - jump forwards to the start of a word (words can contain punctuation)
e - jump forwards to the end of a word
E - jump forwards to the end of a word (words can contain punctuation)
b - jump backwards to the start of a word
B - jump backwards to the start of a word (words can contain punctuation)
% - move to matching character (default supported pairs: '()', '{}', '[]' - use :h matchpairs in vim for more info)
0 - jump to the start of the line
^ - jump to the first non-blank character of the line
$ - jump to the end of the line
g_ - jump to the last non-blank character of the line
gg - go to the first line of the document
G - go to the last line of the document
5G - go to line 5
fx - jump to next occurrence of character x
tx - jump to before next occurrence of character x
Fx - jump to previous occurence of character x
Tx - jump to after previous occurence of character x
; - repeat previous f, t, F or T movement
, - repeat previous f, t, F or T movement, backwards
} - jump to next paragraph (or function/block, when editing code)
{ - jump to previous paragraph (or function/block, when editing code)
zz - center cursor on screen
Ctrl + e - move screen down one line (without moving cursor)
Ctrl + y - move screen up one line (without moving cursor)
Ctrl + b - move back one full screen
Ctrl + f - move forward one full screen
Ctrl + d - move forward 1/2 a screen
Ctrl + u - move back 1/2 a screen
Tip Prefix a cursor movement command with a number to repeat it. For example, 4j moves down 4 lines.
i - insert before the cursor
I - insert at the beginning of the line
a - insert (append) after the cursor
A - insert (append) at the end of the line
o - append (open) a new line below the current line
O - append (open) a new line above the current line
ea - insert (append) at the end of the word
Esc - exit insert mode

Releases

No releases published

Packages

No packages published