Purdue Linux Users Group Presents Linux 201: Session 1 Everything you ever wanted to do in VIM Thor Smith.

Slides:



Advertisements
Similar presentations
A Guide to Unix Using Linux Fourth Edition
Advertisements

Editing with vi Or more fun than you thought you’d have without a mouse Prof. Chris GauthierDickey.
Program Development Tools IDE vs point tools Two tool flavors exist for developing embedded software: -IDEs: (Integrated Development Environments) i.e.,
CIS 240 Introduction to UNIX Instructor: Sue Sampson.
VIM: The basics Tang Wai-Chung, Matthew (MaFai) 29/12/2006.
Vi Editor TA for ITIS3100: Xu Fei
Chapter 5 Editing Text Files
1 Using Editors Editors let you create and edit ASCII files UNIX normally includes two editors: vi and Emacs Vi and Emacs are screen editors: they display.
CS 497C – Introduction to UNIX Lecture 9: The vi/vim Editor Chin-Chih Chang
Starting Vi Opening an existing file vi filename Creating a new file vi filename In your workshop directory, create a new file called mysong vi mysong.
Formatting and Editing Skills
CSCI 330 T HE UNIX S YSTEM Editing files. E DITOR C ONCEPTS Editing a file is to modify the content of a file Text editor: Enter and modify text in a.
1 Unix Editors (ee, ed, ex, vi, vim) and Compilers (g77, gcc) Speaker: Li-Wen Chen Date:
Chapter 3 Mastering Editors
Basic Text Processing, Redirection and Pipes. 222 Lecture Overview  Basic text processing commands head, tail, wc  Redirection and pipes  Getting to.
T HE VI EDITOR. vi has 2 modes: command mode (initial or "default" mode) insert mode [Esc] is used to switch to command mode. In general, vi commands:
Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 7 Editing.
Introduction to Vim Robbie CSCI2100 Data Structures Tutorial 3.
1 © 2014 John Urrutia. All rights reserved. Chapter 7 The “ Emacs “ Editor.
UNIX Intro vi  vi is the standard UNIX text editor v Contents 1.Why use vi ? 2. vi Basics 3.Moving Around 4.Inserting Text.
Text editors Why should I use an editor ? It is very important to able to use at least one text mode editor a text mode editor is so useful on remote machines.
Unix Editors. u Editors in Unix come in two general flavours: –modal editors have "modes" v generally input mode and command mode –input mode allows entry.
Tony Kombol.  Why text edit?  Many programs and features require configuration ▪ Configuration is kept in files ▪ Usually in the /etc directory  Changes.
Unix Session IV.
Text Editing February 2 nd, 2004 Class Meeting 3.
Chapter Three Text Editing1 System Programming Text Editing.
Unix Environment Input Output 2  List Content (ls) ◦ ls (list current directory) ◦ ls –all (include hidden files/folders)  Make directory (mkdir) ◦
VI EDITOR University of Mississippi. Vi Editor What is Vi ? ▫Vi is a screen based editor. ▫The screen of your terminal will act as a window into the file.
1 © 2012 John Urrutia. All rights reserved. Chapter 6 The vi Editor.
Lesson 4-Mastering the Visual Editor. Overview Introducing the visual editor. Working in an existing file with vi. Understanding the visual editor. Navigating.
Isecur1ty training center Presented by : Eng. Mohammad Khreesha.
Agenda Using vi Editor Starting vi Session Command / Input Modes Entering Text Editing Text Saving Edited File Aborting Editing Session.
Agenda Using vi Editor Starting vi Session Command / Input Modes
Vi editor Pronounced: `vee eye‘’. Agenda Describe the background of vi Editor Use vi editor to: create text files edit text files Our Goal is to create.
Microsoft Word 2000 Presentation 3 Microsoft Word Topics Wizards –Letters –Envelopes and Labels Quick Navigation of Documents –Keyboard short-cuts Editing.
Advanced Vim (Vi Improved). Announcement Managements requests that all the Emacs chauvinist in the audience refrain from arguing with the Vim chauvinist.
CS:414 introduction to Unix and Linux
Vim basics Vi IMproved.
What Every Vi User Should Know about Vim
Guide To UNIX Using Linux Third Edition
Formatting and Editing Skills
Vi Editor.
Unix Fundamentals - Part iii vi Editor
Vim.
Vi Introduction Tony Kombol.
Linux 104 Training Module File Editing.
Lecture 3 More on editors: emacs and vi COP 3344 Introduction to UNIX.
IT244 - Introduction to Linux / Unix Instructor: Bo Sheng
Practice #0: Introduction
Technical University of Kosice
Formatting and Editing Skills
Document Processing Part 2
Program Development with Vim
Text Editors Vim (Chapter 6) Emacs (Chapter 7)
Basic gvim commands.
CREATING, PRINTING, AND EDITING DOCUMENTS
Formatting and Editing Skills
بسم الله الرحمن الرحيم.
Formatting and Editing Skills
Chapter 2 Basic vi Editor.
Lesson 1 - Automating Tasks
The Emacs Editor Read: Forouzan, Appendix C
Formatting and Editing Skills
Formatting and Editing Skills
CSCI The UNIX System Editing files
Formatting and Editing Skills
Formatting and Editing Skills
In the last class… The vi basics command, input and ex mode
The Linux Command Line Chapter 12
Presentation transcript:

Purdue Linux Users Group Presents Linux 201: Session 1 Everything you ever wanted to do in VIM Thor Smith

Movement

Use the Home Row Keys ● h – Move Left ● j – Move Down ● k – Move Up ● l – Move right

Jump Around the Window ● :set number – Display line nums ● H – Top of Window ● M – Mid of Window ● L – Bottom of window

Move To Beginning and End of Lines ● ^- First character ● $- Last character ● |- Beginning of Line ● % - Move between parentheses/brackets

Move Between Words ● w - next word (first letter) ● b - prev word (first letter) ● e – next word (last letter) ● ge – prev word (last letter)

Move Between Characters ● t(c) – move forward just before c ● f(c) – move forward just after c ● T(c) – move backward just before c ● F(c) – move backward just after c

Move Around the File ● G – last line of file ● gg – first line ● 2 gg – second line ● z – center around line ● :2 – second line ● Page Up/Page Down

Editing

Insert Mode ● i – enter insert mode ● [esc] – exit insert mode

Deleting, Yanking, and Pasting ● Delete (Cut): The text that's deleted is removed from the file and put into the default register. ● Yank (Copy): The text that's yanked is copied into the default register. ● Paste: Text in default register inserted at cursor. ● Other Registers: Any letter can be used as a register by prefixing it with a double quote. Ex1: “a yy Ex2: “b ddEx3: “a p

Delete and Replace Characters ● x – delete character – (better than backspace) ● r – replace character ● ~ - increment number

Delete (Cut) Lines ● dd – delete 1 line ● 2dd – delete 2 lines ● d$ -- delete from cursor to end of line ● d^ -- delete from cursor to first character in line.

Yank (Copy) Lines ● yy – yank 1 line ● 2yy – yank 2 lines ● y$ -- yank from cursor to end of line ● y^ -- yank from cursor to first character in line.

Generalized Deleting and Yanking ● The letter “d” or “y” followed by any movement command will delete or yank from the cursor to that position. ● d(movement)or y(movement) ● dw y% ● d2w y3e ● dG y128gg ● dtryf)

Join Lines of Text ● J – appends the line below to the current line.

Indenting Lines of Code ● >> - indent one line to the right ● << - indent one line to the left ● 2>> - indent two lines to the right ● 2<< - indent two lines to the left ● == - auto-indent one line of code ● 10== - auto-indent 10 lines of code

Indenting Lines of Code ● >, <, and = have the same form as d, and y. However, they affect whole lines. ● >G – indent all lines from cursor to end of file ● <12gg – unindent all lines from cursor to line 12 ● =L – auto-indent all lines from cursor to bottom of screen

Undo/Redo ● u – undo last edit ● ^R – redo last edit

Advanced Insert Mode ● a – insert after cursor ● A – insert at end of line ● I – insert at beginning of line ● s – replace character and edit. ● o – new line below ● O – new line above

Advanced Editing, Macros ● qc – start recording 'c' ● q – stop recording – execute recording 'c' ● - execute last recording ● execute last recording 12 times.

Search & Replace

Searching Backwards and Forwards ● Search Highlighting ● :set hlsearch ● /the – search forwards for “the” ● ?the – search backwards for “the” ● n – next match ● N – previous match

Replace ● Replace “hi” with “lo” for all “hi” in the file. ● :%s/hi/lo/g ● Same thing, but ask me before each replacement. ● :%s/hi/lo/gc

Customizing

.vimrc File ● Goes in your home directory ● Whenever you start a new vim session, vim references this file if it exists and runs all of the commands in it. ● A.vimrc file can be run inside of a vim session by typing: – :source ~/.vimrc

Useful Configurations ● Line numbers: – :set number ● Highlighted Searching – :set hlsearch ● Pasting code into vim (preserve indentation) – :set paste→ Turns on pasting – :set nopaste→ Make sure to turn it off!

Controlling Indentation and Tabs ● Set tab width to a reasonable length – :set tabstop=2 ● Set automatic indentation when coding – :set autoindent – :set smartindent ● Set indentation width (different from tab width) – :set shiftwidth=2

Open Multiple Tabs!!! ● vim -p file1 file2 ● :tabnew file3 – open new tab for file3 ● gt – switch to next tab ● gT – switch to previous tab ● :q – quit tab

Multiple Windows ● ^wv – split windows vertically ● ^ws – split windows horizontally ● ^ww – move to next window

Resources ● Vim Documentation: (for cards) ●

Questions?

Announcements ● Linux 201 Session 2: Python is Feb 13 th here from 7-8pm