CS2043 - Unix Tools & Scripting Lecture 8 Vim And Tmux

2y ago
59 Views
1 Downloads
369.05 KB
28 Pages
Last View : 19d ago
Last Download : 3m ago
Upload by : Dahlia Ryals
Transcription

CS2043 - Unix Tools & ScriptingLecture 8Vim and TmuxSpring 20151Instructor: Nicolas SavvaFebruary 6, 20151based on slides by Hussam Abu-Libdeh, Bruno Abrahao and David Slater over the yearsInstructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

AnnouncementsRemaining CSUGLab accounts activatedA2 is due Saturday 02/07A3 coming out within the next 24hrsInstructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

TodayText editor: vimMultiplexing terminals: screen / tmuxInstructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

Vim Awesome!Vim is a powerful lightweight text editor.The name “Vim” is an acronym for “Vi IMproved”vi is an older text editorPorts of Vim are available for all systemsincluding Microsoft WindowsVim allows you to perform text editing tasks much faster thanmost other text editors!Though it does have a learning curveInstructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

A modal text editorOne of the reasons that Vim allows you to performs tasksquickly is because it works in modes.Without modes, users would have to either use commandmenus (with a mouse or keyboard), or use complex/longcommand shortcut keys involving the control key (ctrl) orthe alt key (alt).Vim uses modes to speed up editing by not relying oncommand keys or menus.You can do all of your editing by just using the keyboard which issuper fast!!Instructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

The 3 main modes of VimNormal mode:Launching pad to issue commands or go into other modesAllows you to view the text but not edit itVim starts in normal modeYou can jump to normal mode by pressing the Escape (Esc)key on your keyboardVisual mode:Used to highlight text and perform operations on selected textYou get to visual mode from normal mode by pressing the vkey on your keyboardInsert mode:Used to type text into the buffer (file)This probably what you’re used to from your text editorYou get to the insert mode by pressing the i key on yourkeyboardInstructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

Command line commandsYou can issue “command-line commands” from inside Vim toperform some functionalitieswrite to disk, quite, get help, split screen, .etcTo issue a command, go to normal mode and the type :followed by your commandLaunching Vim help:helpInstructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

Moving aroundFastYou can use your mouse to move around in Vim (assuming agraphical interface as in gVimFasterHowever it is much faster to just use your keyboard, and for thatyou can just use the arrow keys to move up/down/left/right.FastestYou can even be more efficient by not leaving the main area of thekeyboard and using “h” to go left, “j” to go down, “k” to go up,and “l” to go right.To start off, I recommend you just use the arrow keys.Instructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

Getting startedTo get started, launch Vim and go through the built in help.:helpYou can search for help on a specific topic as well.:help [topic to search for]Instructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

Helpful commandsI can’t possibly teach you about all the power of Vim in a fewminutes, however here are a few commands to help you get started.Getting help:helpEntering normal mode Esc Entering insert mode (from normal) i Entering visual mode (From normal) v Instructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

Helpful commandsSave text to filename.txt:w filename.txtExit:qQuit without saving:q!Open another file:e [filename]Instructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

Helpful commandsTurn on syntax highlighting:syntax onTurn on line numbering:set numberTurn on spell check:set spellInstructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

Helpful commandsSplit screen horizontally:spSplit screen vertically:vspMove between split regions ctrl-w w Instructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

The most helpful commandThe Most Helpful Command By Far:helpInstructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

GUI VimVim can run right in your shell, but there are also implementationsof it that run in a nice GUI window (with menus, toolbars, andmouse)Use gVim for thatMacVim for Mac OS XInstructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

Useful linksVim project websitehttp://www.vim.org/Vim tips and tmlVim recipeshttp://vim.runpaint.org/toc/Instructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

Bash isn’t PerfectThere are a few problems with your basic BASH session. Some ofthese you may even have encountered already:Your session isn’t preserved if you close your ssh connectionIt’s a pain to switch back and forth between files/the prompt.Sometimes using two or three shells at once would be reallyconvenient!All of these complaints can be resolved by using screen.Instructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

Intro To ScreenThe screen commandscreen - a screen manager with terminal emulationGenerally screen can be used just as you would normally use aterminal window. However, special commands can be used to allowyou to save your session, create extra shells, or split the windowinto multiple independent panes.Passing Commands to screenEach screen commands consists of a CTRL-a (hereafter referredto as C-a) followed by another character.Instructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

Using ScreenAttach a screenscreen [options]Opens a new screen for use-a : include all capabilitiesResume a screenscreen -r [pid.tty.host]Resumes a detached screen sessionscreen -x [pid.tty.host]Attach to a non-detached screen sessionIf you only have one screen, the [pid.tty.host] string is unnecessary.Instructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

Identifying Screen SessionsScreen Listingscreen -ls or screen -listLists your screen sessions and their statusesThese screen sessions are the [pid.tty.host] strings required forresumingResuming a screenIf screen -ls returns 15829.pts-9.rumman (Detached)screen -r 15829.pts-9.rumman to resume the screenNote: You only need to specify the full “name” of the session ifyou have multiple sessions open. If you just have one session, justuse screen -rInstructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

Creating More ShellsCreates a New Shell WindowC-a cCreates a new shell in a new window and switches to itUseful for opening multiple shells in a single terminalSimilar to tabbed browsing/tabbed IMsBut how do we switch between windows? (hint: every window isnumbered by order of creation)Window SelectionC-a 1 - switches to window 1 C-a 9 - switches to window 9Instructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

Splitting ScreenSplit Screen ComputingC-a S - splits your terminal area into multiple panesC-a tab - changes the input focus to the next paneThe ’S’ is case-sensitiveEach split results in a blank paneUse C-a c to create a new shell in a paneUse C-a num to move an existing window to a paneNote:When you reattach a split screen, the split view ill be gone. Justre-split the view, then switch between panes and reopen the otherwindows in each with C-a num Instructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

Now lets put this together to do something usefulSuppose you are doing some serious scientific computing and wantto run it on a remote server. We can put together what we havelearned to do this efficiently:ssh into the remote machinessh slater@boom.cam.cornell.edustart screenscreenstart mathematicamath BatchJob.mrenice the math kernel so other uses can use the machinerenice -20 PIDDetach the screen, logout, and come back 8 hours later whenit is doneInstructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

Terminal Multiplexer tmuxConcurrently view/manage multiple programs in one terminalRead documentation (key-binding / configuration)Edit .tmux.confInstructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

tmux - what it looks likeInstructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

tmux - cheatsheetInstructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

tmux - check the websitehttp://tmux.sourceforge.net/Instructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

Next TimeInstructor: Nicolas SavvaCS2043 - Unix Tools & Scripting Lecture 8 Vim and Tmux

Resume a screen screen -r [pid.tty.host] Resumes a detached screen session screen -x [pid.tty.host] Attach to a non-detached screen session If you only have one screen, the [pid.tty.host] string is unnecessary. Instructor: Nicolas Savva CS2043 - U

Related Documents:

Shell, Unix lesystem, basic tools Combining tools/commands (pipe'ing) Advanced tools Regular expressions Stream manipulation Scripting Shell scripting Python scripting Instructor: Bruno Abrahao CS2043 - Unix Tools & Scripting. What are scripts? Programs written for a special run-time environment that can

Introduction of Chemical Reaction Engineering Introduction about Chemical Engineering 0:31:15 0:31:09. Lecture 14 Lecture 15 Lecture 16 Lecture 17 Lecture 18 Lecture 19 Lecture 20 Lecture 21 Lecture 22 Lecture 23 Lecture 24 Lecture 25 Lecture 26 Lecture 27 Lecture 28 Lecture

Week 3 Lecture 3: Unix and You 1 / 50 / Announcements Basic 2, and Advanced 2 are out Lecture 2 survey is closing today Lecture 3: Unix and You 2 / 50 / Unix and You Lecture 3 Where I try not to turn this into an OS lecture Lecture 3: Unix and You 3 / 50 / Overview 1. What is Unix? 2. How d

Unix 101: Introduction to UNIX (i.e. Unix for Windows Users) Mark Kegel September 7, 2005 1 Introduction to UNIX (i.e. Unix for Windows Users) The cold hard truth · this course is NOT sponsored by the CS dept. · you will not receive any credit at all introduce ourselv

UNIX and POSIX APIs: The POSIX APIs, The UNIX and POSIX Development Environment, API Common Characteristics. UNIT – 2 6 Hours UNIX Files: File Types, The UNIX and POSIX File System, The UNIX and POSIX File Attributes, Inodes in UNIX

Applications of traditional scripting languages are: 1. system administration, 2. experimental programming, 3. controlling applications. Application areas : Four main usage areas for scripting languages: 1. Command scripting languages 2.Application scripting languages 3.Markup language 4. Universal scripting languages 1.

The main features of php is; it is open source scripting language so you can free download this and use. PHP is a server site scripting language. It is open source scripting language. It is widely used all over the world. It is faster than other scripting language. Some important features of php are given below; Features of php

appointment. If you cancel: 25.1. any time up to 24 hours before the appointment you will receive a full refund; and 25.2. within 24 hours of the appointment, you will not receive any refund. 26. Refunds will only be paid to the cardholder or person who made the original payment and will be made through the same means as payment was made. 27 .