/************************************************************/ /********** editor presentation **********/ /********** notes from austin linux meetup presentation *****/ /********** given 02-02-2009 by bob carnaghi **********/ /************************************************************/ /********** the vi editor **********/ -> a ubiquitous command-line editor that is included on nearly every installation of Linux -> typically runs in either of two modes: insert mode, or command mode. -> insert mode allows direct editing of text that works only on individual characters. Insert mode is simple compared to command mode. -> press the escape key to get out of insert mode and into insert mode. -> command mode allows commands that will work on lines, blocks of text, read external files, utilize shell commands, etc. /************************************************************/ /********** the following sections are command mode *********/ /********** moving around **********/ -> 'b' moves backward one word; '2b' moves backward two words, etc. -> 'w' moves forward one word; '2w' moves forware two words, etc. -> '$' moves to end of line, doesn't open insert mode -> '0' (zero) moves to beginning of current line, doesn't open insert mode -> ']]' moves to end of document -> '{' moves backward (up the document) by one section (typically to next empty line) -> '[[' moves to beginning of document -> '}' moves forward by one section (typically to next empty line) -> 'gg' goes to beginning of document -> 'shift + g' goes to end of document -> '25' then 'shift + g' goes to line #25, etc. -> 'enter' moves down one line -> the arrow keys move around one character at a time -> 'H' move to top of visible screen -> 'M' move to middle of visible screen -> 'L' move to last line of visible screen /********** **********/ /********** inserting text **********/ -> 'o' opens a new line below the cursor, and enters insert mode -> 'O' opens a new line above the cursor, and enters insert mode -> 'a' enters insert mode after current cursor location -> 'A' enters insert mode at end of current line -> 'i' enters insert mode directly under current cursor location -> 'I' enters insert mode at beginning of current line /********** **********/ /********** copying text **********/ -> 'yy' yanks (copies) current line; 2yy yanks 2 lines, etc. -> 'dd' deletes (cuts) current line; 2dd deletes (cuts) two lines, etc. -> 'p' puts (pastes) whatever was yanked or deleted below cursor -> 'y2w' yanks (copies) two words, etc. -> 'd2w' deletes (cuts) two words, etc. /********** **********/ /********** searching & replacing text **********/ -> '/text' searches for 'text' in the document -> 'n' repeats the search forward through the document -> 'N' repeats the search backward through the document -> ':s/old/new' replaces first occurrence of old with new on current line -> ':s/old/new/g' replaces all occurrences of old with new on current line -> '50,100s/old/new/g' replacess all occurrences of old with new on lines 50 to 100 -> ':%s/old/new/g' replaces all occurrences of old with new in entire document -> ':%s/old/new/gc' replaces all occurrences of old with new in entire document with confirmations /********** **********/ /********** writing/saving/quitting the file/session ********/ -> ':w' writes (saves) current file -> ':q' quits session, must not be any changes to file -> ':q!' quits session, discard all changes -> ':x' write, save, and quit session /********** **********/ /********** miscellaneous **********/ -> ':R' replace mode, will type over text and replace it with whatever you type -> ':set nu' displays line numbers; place in the ~/.vimrc file for automatic initialization when starting the editor; see section below -> type 'vimtutor' at the command line for a nice tutorial that will refresh your memory on vi usage -> ': set ignorecase' for case insensitive searches -> ':set wrapscan' to automatically repeat searches from beginning of document after reaching end of document -> '!command' executes bash command outside vim editor, shows result in editor -> ':r file.txt' reads external file.txt into current vim session at cursor location -> 'u' undoes whatever you just did /********** **********/ /********** establishing some initial vim settigns **********/ 1. Start editing the "vimrc" file. Ensure that the 'vim-runtime' package is installed. 'cd' to your home directory, and enter 'vi .vimrc' 2. Now read the example "vimrc" file contents: :r $VIMRUNTIME/vimrc_example.vim 3. Write the file with: :w /********** **********/ /********** resources **********/ the guru extraordinaire of vim: Bram Moolenaar tutorial: http://www.eng.hawaii.edu/Tutor/vi.html commands: http://www.cs.rit.edu/~cslab/vi.html vim home: http://www.vim.org/ NOTE: ubuntu does some WEIRD stuff with vi because it installs, by default, 'vim-tiny'. Uninstall 'vim-tiny' and install 'vim', which will also install 'vim-runtime'. /************************************************************/ /********** **********/ /************************************************************/ /********** gedit editor **********/ included with most distributions (ubuntu, mandriva, centos) typical gui text editor that is very versatile extremely handy for all types of editing that does not require fancy formatting used for creating bash scripts customization: edit -> preferences -> view 1. enable 'display line numbers' 2. enable 'highlight current line' 3. enable 'highlight matching bracket' edit -> preferences -> plugins 1. enable 'change case' (found under 'edit' pulldown) 2. enable 'document statistics' (found under 'tools' pulldown) 3. enable 'file browser pane' (found under 'view' pulldown) 4. enable 'indent lines' (found under 'edit' pulldown) 5. enable 'insert date/time' (found under 'edit' pulldown) 6. enable 'modelines' 7. enable 'snippets' (found under 'tools' pulldown) 8. enable 'sort' (found under 'edit' pulldown) 9. enable 'spell checker' (found under 'tools' pulldown) 10. enable 'user name' (found under 'edit' pulldown) /************************************************************/ open source alternatives is http://www.osalt.com. http://whdb.com/2008/the-top-50-proprietary-programs-that-drive-you-crazy-an d-their-open-source-alternatives/ try this link: http://www.roseindia.net/opensource/html-editor-open-source.shtml