LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Blogs > omgiamlinux
User Name
Password

Notices


Rate this Entry

Day 1: My very first (and most terrible) VI notes

Posted 10-27-2011 at 08:29 PM by omgiamlinux
Updated 10-27-2011 at 08:37 PM by omgiamlinux

Notes: VI is a very slow thing to learn, but it's well worth taking the time learning it. It makes working on code, almost like a very fun logic game. It's also the fastest way to program in any language (well... faster than 'notepad' style text editors hands down anyway). The only reason everyone doesn't use VIM and EMACS is because the software really does take quite a while to get the hang of. Anyway, each blog entry I make on VIM, you should mul over a lot and practice until you get the hang of the features, and then move on to the next entry to expand your feature set.

(terrible) VI notes:
Ok, vi is a text editor. It's terrible... But it works good in a terminal window. And I'm being overly critical of vi, it actually grows on you quite quickly. So here's what goes through my mind when I try to use it.
Code:
TEXT INPUT MODE:
hit "i" for "insert" to enter text editing mode
DO NOT hit the numpad keys, they won't do what you want
right click on putty.exe's window to paste your clipboard into the terminal.  

COMMAND MODE:
hit esc to get back into command mode.
hit delete key when in command mode to delete lines.
hit the arrow keys to move about the page.  
hit "dd" to delete a line.
hit "u" when you've made a mistake to undo changes to the line.

hit "/ STRING" to search the file for STRING, forward.
hit "? STRING" to search the file for STRING, backward.

hit "n" to repeat your last command.


TEXT SELECTION
hit "V" to begin highlighting text.  
hit "y" to Copy (aka "yank").
hit "p" to Paste.


GETTING OUT
hit ":wq" to save and quit.
hit ":q!" to quit with out saving.  

SYNTAX HIGHLIGHTING
hit ":syntax on" to have comments a special color, strings a different color, etc.
hit ":syntax off" if that gets boring.
I've recently discovered that vim exists too, and works just like vi only it must have some "improved" features...
Turn syntax on (and set syn=ruby) automatically:
ref: http://ubuntuforums.org/archive/index.php/t-112119.html
Why people think vim is just swell:
ref: http://www.vim.org/scripts/script.php?script_id=1567

VI Notes 2:
Code:
http://www.youtube.com/watch?v=J1_CfIb-3X4

:set incsearch   ~~ turns on incremental search... type /pattern  in vi to see what I mean
*                ~~ Search for next occurance of word at cursor
f<letter>        ~~ Searches for the next occurance of the specified letter (eg. fa)                 
	;               ~~ go to the next one down
	,               ~~ go back to the previous one

de               ~~ delete to end of word

:%s              ~~ FIND AND REPLACE!

:%s/bla/blaa/g   ~~ for the whole file... replace... / 'bla' / with 'blaa' / Can be more than once per line


gg  ~~beggining of file
G   ~~End of file
Lol, looking back, I was such a noob for so very long. I was actually hitting the "INSERT" key on my keyboard every time I wanted to start typing into vi... Who ever told me to do that should be banned from the internet.
Posted in VIM dedication
Views 729 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 12:17 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration