Advanced editingtop
:set nu show line numbers :set nonu hide line numbers :set ic instruct searches to ignore case :set noic instruct searches to be case-sensitive :set list display invisible characters, Tab, EOL etc :set nolist turn off invisible characters :set showmode display current mode of operation :set noshowmode turn off display mode :set displays all vi variables :set all displays all vi vars and current settings
Deletingtop
x delete character at cursor X delete character to right of cursor dw delete word (or part of word to right of cursor) d3w delete 3 words dd delete line at cursor 3dd delete 3 lines from cursor D delete line to right of cursor dG delete to end of file from cursor d3G delete inclusive from line 3 to cursor :5,8 d delete lines 5 to 8 don't forget u undo last change ;)
Editingtop
a insert after cursor A insert at end of line i insert before cursor I insert at beginning of line o insert new line below current line and append O insert new line above current line and append cw change word or part of from cursor to end 3cw change 3 words rx replace current character with x Rtext replace characters with text s replace one character for character(s) u undo last change . repeat last change U undo all changes to current line J join lines yy copy a line 5yy copy 5 lines P paste after cursor p paste before a cursor 5p paste 5 times, same rules as p's above xp transpose char at cursor and char to right of cursor ~ change case at cursor
Findingtop
/me search forward for me ?me search backward for me n forward find next N reverse find next fx find next x on this line Fx find previous x on this line ; find again using last f or F % find matching [({})] braces :%s/old/new/g search and replace globally
mac nginxtop
cd /usr/local/etc/nginx sudo nginx # start sudo nginx -s stop # stop sudo nginx -s reload # reload # open file limit error ulimit -n 1024 brew services restart php56 brew services restart nginx XX brew services restart mysql sudo dscacheutil -flushcache which php brew services list
Movingtop
h move left j move down k move up l move right H move to top of screen M move to middle of screen L move to bottom of screen gg goto start of file G goto end of file 3G goto line 3 :3 goto line 3 0 start of line $ end of line b back a word e end of word w move forward one word ^d scroll down half screen ^f scroll down full screen ^u scroll up half screen ^b scroll up full screen nG goto line n
openingtop
vi filename open for editing vi open new file to be named later view filename open in read-only mode
save and quittop
:w save changes :w new_file save changes to new file :wq save changes and quit ZZ save changes and quit :q! quit without saving changes
virtualbox on mactop
1. install guest additions https://help.ubuntu.com/community/VirtualBox/GuestAdditions 2. Configure shared folder in virtual box name (www-on-mac) is / point to folder on mac (Users/username/folder) 3. Mount it with command in "ubuntu" virtualmachine ssh mount -t vboxsf www-on-mac /var/www/html (this is folder on ubuntu guest) #add your user and www-data sudo adduser <username> vboxsf