Vim Cheat Sheet for Programmers May Be Freely Distributed! Http:/Michael.Peopleofhonoronly.Com/Vim/ Sept

Total Page:16

File Type:pdf, Size:1020Kb

Vim Cheat Sheet for Programmers May Be Freely Distributed! Http:/Michael.Peopleofhonoronly.Com/Vim/ Sept Revision 2.0 Vim 7.3+ Copyleft © 2011 Esc Normal Vim Cheat Sheet for Programmers May be freely distributed! http:/michael.PeopleOfHonorOnly.com/vim/ Sept. 11, 2011 :version Sharing is Caring. HOW-TO make Vim not suck Out of the Box: :help statusline :set nocompatible ruler laststatus=2 showcmd showmode number Search :set incsearch ignorecase smartcase hlsearch Remove useless splash screen :set shortmess+=I Best tips: http://vim.wikia.com/ Best scripts: http://www.vim.org/scripts/index.php :map <F9> :e $HOME/_vimrc<CR> :map <F6> :so $HOME/_vimrc<CR> Ctrl ` Ctrl 1 Ctrl @ Ctrl 3 Ctrl 4 Ctrl 5 Ctrl ^ Ctrl 7 Ctrl 8 Ctrl 9 Ctrl 0 Ctrl _ Ctrl = play prev goto next begin end ~ toggle case extern filter soft repeat :s cur line ! @• macro # identifier $ ⇥ % match ^ ⇤ & * identifier ( sentence ) sentence _ + ↓ 13 1 3 8 auto- 2 `• goto mark hard 1 2 3 4 5 6 7 8 9 0 ⇤ - ↑ = format 14 block select ^w• window… scroll line ↑ 12 :redo 10 ctags return scroll line ↓ half page ↑ Ctrl I prev mark 9 ↑ Normal ctags identifier end ↖ paragraph ex mode WORD ↘ Replace ← until char copy line undo line insert open ⤒ paste ⤒ Q W E WORD ↘ R T• Y U I ⇤ O P { paragraph } ↘ record end replace 0 0 Tab until char → 2 open ⤓ paste ⤓ word ↘ copy undo ↱ insert misc. misc. q• macro w e word ↘ r char t• y u i o p [• ]• 7 incr. # 10 half page ↓ page ↓ file/cursor info Ctrl H 15 Ctrl J redraw Ctrl ; Ctrl ' Ctrl \ goto eof / man page Bottom 0 ⇤ A append ⇥ S subst line D del ⇥ F• ← find char G H Top screen J Join lines K L : cmd line "• register | goto line# identifier screen goto col# ↰ 0 6 "next" 16 goto mark \ Caps a append s subst char d del 2 f• find char → g• extra h ← j ↓ k ↑ l → ; '• \• f/F/t/T ⇤ 7,11 9,16 15 Ctrl ^ :suspend decr. # Normal / Cancel block select page ↑ ↓ Ctrl M Ctrl , Ctrl . Ctrl / Unused & Duplicate keys 4 select "prev" Middle 2 2 \ Ctrl-K Ctrl-S (free) Z• quit X ← del char C change ⇥ V B ↖ WORD N M < undent > indent ?• find ↖ Ctrl-L (redraw) Shift ⇧ lines find screen 13 ` near dup of ' 5 0 select find "prev" 16 repeat 14 Ctrl-Q = Ctrl-V extra del char → change 2 ↖ word set mark find ↘ z• x c v chars b n "next" m• , f/F/t/T . cmd /• 15 Ctrl-J = Ctrl-M = ^N Legend: 16 The search direction is relative; next is the initial direction, previous is the opposite direction. n ; repeat same initial direction find. N , repeat opposite initial direction find. Note: ; , only searches cursor line, n N searches buffer. Macro Register name (0-9a-zA-Z) required :help cmdline :r file insert file Tags \ :map \ :Explore<CR> manually type <,C,R,> :buffer # Op Motion req.; act between cursor & dst :w save :gui switch to GUI :ts list active tags §0 "• before del/copy/paste to use register :buffers list files Cmd Command :q quit :q! quit w/o save ^] jump to tag under cursor "+x cut to system clipboard reg. '+' :new blank file/buffer Ins Command and enter insert mode :e <file> edit file in new buffer ^t restore cursor before tag jump "+gP paste from system clipboard :bn next file Move Moves cursor or defines range for op :source % exec cmds in cur file ^p complete word 1 Number before any action repeats it :bp prev file Find Search (↖ = reverse, ↘ = forward) :exec '...' do cmd :ta Foo manual jump to tag 'Foo' 2p paste twice 3. repeat thrice :bd close file tag ctags / diffs / folding :help movement 2 Repeat op to act on current line :bd!force close Code Code formatting, whitespace, etc. soft ^ ⇤ Start of Line 1st non-whitespace Diff yy copy line dd del line :set lines=# Extra Extended functionality; req. extra chars hard 0 ⇤ Start of Line column 0 [c prev diff :hi DiffAdd guifg=#rrggbb << undent line >> indent line :set columns=# • Char arg req. g z Z ^w ' " ` … $ ⇥ End of Line ]c next diff :hi DiffChange guibg=#rrggbb 3 # highlight words under cursor :winpos # # GUI Modes :help modes | move col 0 #| move col # :diffupdate :hi DiffText gui=none 4 ZZ save & quit ZQ quit w/o save Windows n Normal Esc ^[ ^c ^b page ↑ ^f page ↓ resync :hi DiffDelete 5 zz center cursor line in window :help windows i Insert a i r s ^u ½ page ↑ ^d ½ page ↓ zh scroll left zl scroll right ^w• or :wincmd • v Visual v V ^v ^q ^e scroll line ↑ ^y scroll line ↓ Folding Changes zt scroll top zb scroll bottom w! :switch to next o Op pending c d y < > 1g start of file 0g end of file zR fold remove :changes §6 gg top of file c! :close! c Command Line : / ? ! #g goto line # G end of file zo fold open g; older change gf open file under cursor n! :new s! :split horz. Foo [[ zc g, ^a word ( src , ␢ dst , ␢ len ); begin this func { fold close newer change 7 incr # under cursor (Dec / Hex) v! :vsplit vertical Note: There is no whitespace in-between 'Foo(src,' but before/after 'dst,' ]] begin next func { zi invert all ^x decr # under cursor (Dec / Hex) o! :only maximize WORD Foo ( src , ␢ dst , ␢ len ); :set matchpairs=(:),{:},[:],<:>,?:\: zr fold reduce Syntax 8 * start a "new" search =! all same size Startup % goto matching { } < > [ ] zm fold more :syntax enable Insert mode h! move to win ← j! move to win ↓ vim <filename> +123 :set filetype= ^p ^n goto line 123 :help range 9 prev auto-complete next k! move to win ↑ vim <file> … -t Foo edit at tag 'Foo' :s/Foo/Bar find Foo replace w/ Bar :help recording c cpp sh make perl python 10 ^d undent ^t indent l! move to win → vim <file> … -c "/Foo" cmd: find 'Foo' & edit :s/Foo/Bar/g ...all instances on line q• start recording Note: chose only ONE type! §11 ^x• ^f filename completion :sp! [<filename>] GUI vim -g or gvim start GUI ver. :%s/Foo/Bar apply to whole file @• playback Convert <eol> ^s spelling :set spell! edit in split window GUI Linux :set guifont=ProggyTinyTT\ 12 .,.+# cur line, cur line + # lines q stop recording :set fileformat= ^k dictionary ]s next bad Cursor Bookmarks GUI OSX :set guifont=ProggyTiny\:h11 $ last line '< start of select @@ repeat unix or dos or mac ^t thesaurus :help spell :marks ` ' ^o diff gvimdiff <file1> <file2> [<file3>] '> end of select then :w to convert 12 ^r• paste register 0-9a-zA-Z or … ma mark local 'a' bug Broken Keys Ctrl-I = Tab, Ctrl-[ = ESC Code = < > << >> :set tabstop=# set tab stop every #th col + clipboard (or '*') :help c_CTRL-R 'A goto global 'A' Vim is still unable to map certain keys for your own use… :set backspace=indent,eol,start :set expandtab! toggle hard/soft tabs " last del/copy % filename '' prev location § Caps, Ctrl-1, Ctrl-Shift-1, Ctrl-I, Ctrl-\, etc. allow backspace join lines :set listchars=… tab:>-:trail:-,nbsp:%,eol:$ :set numbers! toggle line numbers File / Directory 0 See: src/ops.c -c "/valid_yank_reg" for "• reg. names :set shiftwidth=# indent width for ai :set list! toggle whitespace :set wrap! toggle linewrap display :Explore or :e . 6 See: src/normal.c -c "/nv_cmds" for g• extra cmds :set autoindent! toggle auto-indent :set colorcolumn=80 visible right margin indicator :set showmatch highlite matching () :set browsedir=… 11 See: src/edit.c -c "/ctrl_x_msgs" for ^x• insert cmds :set lisp lisp indent mode noremap + :s/^/\/\//<CR> block comment noremap - :s/^\/\///<CR> uncomment one of buffer last .
Recommended publications
  • Enterprise View™
    ® Micro Focus ™ Enterprise View Installation Guide Copyright © 2008 Micro Focus (IP) Ltd. All rights reserved. Micro Focus (IP) Ltd. has made every effort to ensure that this book is correct and accurate, but reserves the right to make changes without notice at its sole discretion at any time. The software described in this document is supplied under a license and may be used or copied only in accordance with the terms of such license, and in particular any warranty of fitness of Micro Focus software products for any particular purpose is expressly excluded and in no event will Micro Focus be liable for any consequential loss. Animator®, COBOL Workbench®, EnterpriseLink®, Mainframe Express®, Micro Focus®, Net Express®, REQL® and Revolve® are registered trademarks, and AAI™, Analyzer™, Application Server™, Application to Application Interface™, AddPack™, AppTrack™, AssetMiner™, CCI™, DataConnect™, Dialog System™, Enterprise Server™, Enterprise Server with MTO™, EuroSmart™, FixPack™, LEVEL II COBOL™, License Server™, Mainframe Access™, Mainframe Manager™, Micro Focus® COBOL™, Micro Focus® Studio™, Micro Focus® Server™, Object COBOL™, OpenESQL™, Personal COBOL™, Professional COBOL™, Server Express™, SmartFind™, SmartFind Plus™, SmartFix™, SourceConnect™, SupportLine™, Toolbox™, VS COBOL™, WebSync™, and Xilerator™ are trademarks of Micro Focus (IP) Ltd. IBM® and CICS® are registered trademarks, and IMS™, DB2, DB2/390, DB2 Connect Enterprise Edition, DB2 Connect Personal Edition, COBOL for OS/390, Enterprise. Systems Architecture/390, ESA/390, MVS, MVS/ESA, OS/390, S/390, System/390, VSE/ESA and MFS are trademarks, of International Business Machines Corporation. Netscape Enterprise Server™ is a trademark of Netscape Communications Corporation. Internet Information Server®, Windows 95®, Windows 98®, Windows NT 4.0®, Windows ME® and Windows 2000® are registered trademarks of Microsoft Corporation.
    [Show full text]
  • Unix (And Linux)
    AWK....................................................................................................................................4 BC .....................................................................................................................................11 CHGRP .............................................................................................................................16 CHMOD.............................................................................................................................19 CHOWN ............................................................................................................................26 CP .....................................................................................................................................29 CRON................................................................................................................................34 CSH...................................................................................................................................36 CUT...................................................................................................................................71 DATE ................................................................................................................................75 DF .....................................................................................................................................79 DIFF ..................................................................................................................................84
    [Show full text]
  • The Kate Handbook
    The Kate Handbook Anders Lund Seth Rothberg Dominik Haumann T.C. Hollingsworth The Kate Handbook 2 Contents 1 Introduction 10 2 The Fundamentals 11 2.1 Starting Kate . 11 2.1.1 From the Menu . 11 2.1.2 From the Command Line . 11 2.1.2.1 Command Line Options . 12 2.1.3 Drag and Drop . 13 2.2 Working with Kate . 13 2.2.1 Quick Start . 13 2.2.2 Shortcuts . 13 2.3 Working With the KateMDI . 14 2.3.1 Overview . 14 2.3.1.1 The Main Window . 14 2.3.2 The Editor area . 14 2.4 Using Sessions . 15 2.5 Getting Help . 15 2.5.1 With Kate . 15 2.5.2 With Your Text Files . 16 2.5.3 Articles on Kate . 16 3 Working with the Kate Editor 17 4 Working with Plugins 18 4.1 Kate Application Plugins . 18 4.2 External Tools . 19 4.2.1 Configuring External Tools . 19 4.2.2 Variable Expansion . 20 4.2.3 List of Default Tools . 22 4.3 Backtrace Browser Plugin . 25 4.3.1 Using the Backtrace Browser Plugin . 25 4.3.2 Configuration . 26 4.4 Build Plugin . 26 The Kate Handbook 4.4.1 Introduction . 26 4.4.2 Using the Build Plugin . 26 4.4.2.1 Target Settings tab . 27 4.4.2.2 Output tab . 28 4.4.3 Menu Structure . 28 4.4.4 Thanks and Acknowledgments . 28 4.5 Close Except/Like Plugin . 28 4.5.1 Introduction . 28 4.5.2 Using the Close Except/Like Plugin .
    [Show full text]
  • Kafl: Hardware-Assisted Feedback Fuzzing for OS Kernels
    kAFL: Hardware-Assisted Feedback Fuzzing for OS Kernels Sergej Schumilo1, Cornelius Aschermann1, Robert Gawlik1, Sebastian Schinzel2, Thorsten Holz1 1Ruhr-Universität Bochum, 2Münster University of Applied Sciences Motivation IJG jpeg libjpeg-turbo libpng libtiff mozjpeg PHP Mozilla Firefox Internet Explorer PCRE sqlite OpenSSL LibreOffice poppler freetype GnuTLS GnuPG PuTTY ntpd nginx bash tcpdump JavaScriptCore pdfium ffmpeg libmatroska libarchive ImageMagick BIND QEMU lcms Adobe Flash Oracle BerkeleyDB Android libstagefright iOS ImageIO FLAC audio library libsndfile less lesspipe strings file dpkg rcs systemd-resolved libyaml Info-Zip unzip libtasn1OpenBSD pfctl NetBSD bpf man mandocIDA Pro clamav libxml2glibc clang llvmnasm ctags mutt procmail fontconfig pdksh Qt wavpack OpenSSH redis lua-cmsgpack taglib privoxy perl libxmp radare2 SleuthKit fwknop X.Org exifprobe jhead capnproto Xerces-C metacam djvulibre exiv Linux btrfs Knot DNS curl wpa_supplicant Apple Safari libde265 dnsmasq libbpg lame libwmf uudecode MuPDF imlib2 libraw libbson libsass yara W3C tidy- html5 VLC FreeBSD syscons John the Ripper screen tmux mosh UPX indent openjpeg MMIX OpenMPT rxvt dhcpcd Mozilla NSS Nettle mbed TLS Linux netlink Linux ext4 Linux xfs botan expat Adobe Reader libav libical OpenBSD kernel collectd libidn MatrixSSL jasperMaraDNS w3m Xen OpenH232 irssi cmark OpenCV Malheur gstreamer Tor gdk-pixbuf audiofilezstd lz4 stb cJSON libpcre MySQL gnulib openexr libmad ettercap lrzip freetds Asterisk ytnefraptor mpg123 exempi libgmime pev v8 sed awk make
    [Show full text]
  • Read Book > Unix Programming Tools: AR (Unix), As (Unix), Bcheck, C99, Cfront, Citrus Project, Clig, Command Substitution, Co
    SJUMQAILY1KL » Book » Unix Programming Tools: AR (Unix), as (Unix), Bcheck, C99, Cfront, Citrus Project,... Read eBook UNIX PROGRAMMING TOOLS: AR (UNIX), AS (UNIX), BCHECK, C99, CFRONT, CITRUS PROJECT, CLIG, COMMAND SUBSTITUTION, CONFIGURE SCRIPT, CSCOPE, CTAGS To get Unix Programming Tools: AR (Unix), as (Unix), Bcheck, C99, Cfront, Citrus Project, Clig, Command Substitution, Configure Script, Cscope, Ctags PDF, please click the hyperlink beneath and save the ebook or have access to additional information which might be have conjunction with UNIX PROGRAMMING TOOLS: AR (UNIX), AS (UNIX), BCHECK, C99, CFRONT, CITRUS PROJECT, CLIG, COMMAND SUBSTITUTION, CONFIGURE SCRIPT, CSCOPE, CTAGS ebook. Download PDF Unix Programming Tools: AR (Unix), as (Unix), Bcheck, C99, Cfront, Citrus Project, Clig, Command Substitution, Configure Script, Cscope, Ctags Authored by Source Wikipedia Released at 2016 Filesize: 2.1 MB Reviews Without doubt, this is actually the best operate by any article writer. Indeed, it can be perform, nonetheless an interesting and amazing literature. Its been written in an exceedingly straightforward way in fact it is only soon after i finished reading through this book through which in fact changed me, modify the way in my opinion. -- Miss Elissa K utch V Most of these pdf is the ideal pdf available. It is definitely basic but shocks within the 50 percent of your book. I am just easily could get a delight of reading through a written book. -- Jany Crist This book will never be easy to start on looking at but quite entertaining to read. It is actually packed with wisdom and knowledge It is extremely difficult to leave it before concluding, once you begin to read the book.
    [Show full text]
  • Learning the Vi and Vim Editors Other Resources from O’Reilly
    Learning the vi and Vim Editors Other resources from O’Reilly Related titles vi Editor Pocket Reference The Productive Programmer Unix in a Nutshell Unix Power Tools Classic Shell Scripting Mac OS X for Unix Geeks oreilly.com oreilly.com is more than a complete catalog of O’Reilly books. You’ll also find links to news, events, articles, weblogs, sample chapters, and code examples. oreillynet.com is the essential portal for developers interested in open and emerging technologies, including new platforms, pro- gramming languages, and operating systems. Conferences O’Reilly Media brings diverse innovators together to nurture the ideas that spark revolutionary industries. We specialize in documenting the latest tools and systems, translating the inno- vator’s knowledge into useful skills for those in the trenches. Visit conferences.oreilly.com for our upcoming events. Safari Bookshelf (safari.oreilly.com) is the premier online refer- ence library for programmers and IT professionals. Conduct searches across more than 1,000 books. Subscribers can zero in on answers to time-critical questions in a matter of seconds. Read the books on your Bookshelf from cover to cover or sim- ply flip to the page you need. Try it today for free. main.title Page iii Monday, May 19, 2008 11:21 AM SEVENTH EDITION Learning the vi and VimTomcat Editors™ The Definitive Guide Arnold Robbins, ElbertJason Brittain Hannah, and and Ian Linda F. Darwin Lamb Beijing • Cambridge • Farnham • Köln • Sebastopol • Taipei • Tokyo Learning the vi and Vim Editors, Seventh Edition by Arnold Robbins, Elbert Hannah, and Linda Lamb Copyright © 2008 Arnold Robbins, Elbert Hannah, and Linda Lamb.
    [Show full text]
  • Download Vim Tutorial (PDF Version)
    Vim About the Tutorial Vi IMproved (henceforth referred to as Vim) editor is one of the popular text editors. It is clone of Vi editor and written by Bram Moolenaar. It is cross platform editor and available on most popular platforms like Windows, Linux, Mac and other UNIX variants. It is command-centric editor, so beginners might find it difficult to work with it. But once you master it, you can solve many complex text-related tasks with few Vim commands. After completing this tutorial, readers should be able to use Vim fluently. Audience This tutorial is targeted for both beginners and intermediate users. After completing this tutorial, beginners will be able to use Vim effectively whereas intermediate users will take their knowledge to the next level. Prerequisites This tutorial assumes that reader has basic knowledge of computer system. Additionally, reader should be able to install, uninstall and configure software packages on given system. Conventions Following conventions are followed in entire tutorial: $ command execute this command in terminal as a non-root user 10j execute this command in Vim’s command mode :set nu execute this command in Vim’s command line mode Copyright & Disclaimer Copyright 2018 by Tutorials Point (I) Pvt. Ltd. All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish any contents or a part of contents of this e-book in any manner without written consent of the publisher. We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors.
    [Show full text]
  • Vim for C Programmers
    Vim for C Programmers http://interactive.linuxjournal.com/node/8289/print Vim for C Programmers By Girish Venkatachalam Created 2005-10-31 02:00 Thank you for subscribing to Linux Journal. You don't have to move to an integrated development environment to get luxury coding features. From variable autocompletions all the way up to integration with ctags and make, Vim makes a C programmer's life easier and more productive. Vim is an extremely powerful editor with a user interface based on Bill Joy's almost 30-year-old vi, but with many new features. The features that make Vim so versatile also sometimes make it intimidating for beginners. This article attempts to level the learning curve with a specific focus on C programming. make and the Compile-Test-Edit Cycle A typical programmer's routine involves compiling and editing programs until the testing proves that the program correctly does the job it is supposed to do. Any mechanism that reduces the rigor of this cycle obviously makes any programmer's life easier. Vim does exactly that by integrating make with Vim in such a way that you don't have to leave the editor to compile and test the program. Running :make from inside of Vim does the job for you, provided a makefile is in the current directory. You can change the directory from inside of Vim by running :cd. To verify where you are, use :pwd. In case you are using FreeBSD and want to invoke gmake instead of make from the command line, all you have to do is enter :set makeprg=gmake.
    [Show full text]
  • Modular Information Hiding and Type-Safe Linking for C
    IEEE TRANSACTIONS ON SOFTWARE ENGINEERING, VOL. 34, NO. 3, MAY/JUNE 2008 1 Modular Information Hiding and Type-Safe Linking for C Saurabh Srivastava, Student Member, IEEE, Michael Hicks, Member, IEEE, Jeffrey S. Foster, and Patrick Jenkins Abstract—This paper presents CMOD, a novel tool that provides a sound module system for C. CMOD works by enforcing a set of four rules that are based on principles of modular reasoning and on current programming practice. CMOD’s rules flesh out the convention that .h header files are module interfaces and .c source files are module implementations. Although this convention is well known, existing explanations of it are incomplete, omitting important subtleties needed for soundness. In contrast, we have formally proven that CMOD’s rules enforce both information hiding and type-safe linking. To use CMOD, the programmer develops and builds their software as usual, redirecting the compiler and linker to CMOD’s wrappers. We evaluated CMOD by applying it to 30 open source programs, totaling more than one million lines of code. Violations to CMOD’s rules revealed more than a thousand information hiding errors, dozens of typing errors, and hundreds of cases that, although not currently bugs, make programming mistakes more likely as the code evolves. At the same time, programs generally adhere to the assumptions underlying CMOD’s rules and, so, we could fix rule violations with a modest effort. We conclude that CMOD can effectively support modular programming in C: It soundly enforces type- safe linking and information hiding while being largely compatible with existing practice. Index Terms—Coding tools and techniques, C, modules/packages, information hiding, type-safe linking, CMOD, software reliability.
    [Show full text]
  • Advanced Programming in the UNIX Environment – UNIX Development Tools
    CS631-AdvancedProgrammingintheUNIXEnvironment Slide1 CS631 - Advanced Programming in the UNIX Environment – UNIX development tools Department of Computer Science Stevens Institute of Technology Jan Schaumann [email protected] https://stevens.netmeister.org/631/ Lecture 10: Things That Will Make Your Life Significantly Easier October 5, 2020 CS631-AdvancedProgrammingintheUNIXEnvironment Slide2 Software Development Tools Lecture 10: Things That Will Make Your Life Significantly Easier October 5, 2020 CS631-AdvancedProgrammingintheUNIXEnvironment Slide3 Software Development Tools Lecture 10: Things That Will Make Your Life Significantly Easier October 5, 2020 CS631-AdvancedProgrammingintheUNIXEnvironment Slide4 Software Development Tools UNIX Userland is an IDE – essential tools that follow the paradigm of “Do one thing, and do it right” can be combined. The most important tools are: $EDITOR the compiler toolchain gdb(1) – debugging your code make(1) – project build management, maintain program dependencies diff(1) and patch(1) – report and apply differences between files cvs(1), svn(1), git(1) etc. – distributed project management, version control Lecture 10: Things That Will Make Your Life Significantly Easier October 5, 2020 CS631-AdvancedProgrammingintheUNIXEnvironment Slide5 EDITOR Know your $EDITOR. Core functionality: syntax highlighting efficient keyboard maneuvering setting markers, using buffers copy, yank, fold e.g. blocks search and replace window splitting autocompletion jump to definition / manual page applying external commands
    [Show full text]
  • Answers to Selected Problems
    Answers to selected problems Chapter 4 1 Whenever you need to find out information about a command, you should use man. With option -k followed by a keyword, man will display commands related to that keyword. In this case, a suitable keyword would be login, and the dialogue would look like: $ man -k login ... logname (1) - print user’s login name ... The correct answer is therefore logname.Tryit: $ logname chris 3 As in problem 4.1, you should use man to find out more information on date. In this case, however, you need specific information on date, so the command you use is $ man date The manual page for date is likely to be big, but this is not a problem. Remember that the manual page is divided into sections. First of all, notice that under section SYNOPSIS the possible format for arguments to date is given: NOTE SYNOPSIS date [-u] [+format] The POSIX standard specifies only two This indicates that date may have up to two arguments, both of arguments to date – which are optional (to show this, they are enclosed in square some systems may in brackets). The second one is preceded by a + symbol, and if you addition allow others read further down, in the DESCRIPTION section it describes what format can contain. This is a string (so enclose it in quotes) which 278 Answers to selected problems includes field descriptors to specify exactly what the output of date should look like. The field descriptors which are relevant are: %r (12-hour clock time), %A (weekday name), %d (day of week), %B (month name) and %Y (year).
    [Show full text]
  • Ctagsの使い方 Tagging (狭義)
    ctagsの使い方 tagging (狭義) ソースコード中、プログラミング言語の文法の元で名前を付けて定義された 「何か」について 名前、ソースファイル、ファイル中の場所、その他の情報を 組として記録すること。 「何か」には、例えば関数、マクロ、変数、型などがあります。 taggingツールと出力フォーマット ツール フォーマット ツールの出力を活用できるエディタ etags TAGS emacs ctags tags vi, less, 様々 ctagsに -e オプションをつけると TAGSフォーマットでも出力できます。 tags出力の例 入力 (input.c) #include <stdio.h> static boolean debug; #include DEBUG(X) (debug=X) struct point2d {int x, y;}; typedef struct point2d *pp; int distance (pp p0, pp p1) { /* ... */} int main (int argc, char** argv) { int local; /* ... */ goto_label: return 0; } tags出力の例 出力 (tags) $ ctags -o - input.c debug input.c /^static boolean debug;$/;" v file: distance input.c /^int distance (pp p0, pp p1) { \/* ... *\/}$/;" f main input.c /^int main (int argc, char** argv) {$/;" f point2d input.c /^struct point2d {int x, y;};$/;" s file: pp input.c /^typedef struct point2d *pp;$/;" t typeref:struct:point2d file: x input.c /^struct point2d {int x, y;};$/;" m struct:point2d file: y input.c /^struct point2d {int x, y;};$/;" m struct:point2d file: 各行は次の形式をしています。 <名前>tab<ファイル名>tab/<行パターン>/;"tab<KIND>tab... <KIND>については後述します。<KIND>の後に「その他」の情報が続きます。 注意 ツールの出力は完全とは期待できません。特にプリプロセッサによるマクロ展開 を前提とした 入力からは定義をみつけることができません。 $ cat hello-macro.c #include <stdio.h> #define defineEchoFunction(NAME,MESSAGE) \ int NAME(void) { printf("%s\n", MESSAGE); } defineEchoFunction (main, "hello, world) $ ctags -o - hello-macro.c defineEchoFunction hello-macro.c 2;" d file: defineEchoFunction マクロが展開されて定義される関数mainについてctags はそれを発見し損 ねています。 基本的なコマンドラインオプション ctags [オプション] 入力ファイル オプション 意味 -R 「入力ファイル」に指定したディレクトリ以下の全てのファイルを
    [Show full text]