Presentation is loading. Please wait.

Presentation is loading. Please wait.

Technical University of Kosice

Similar presentations


Presentation on theme: "Technical University of Kosice"— Presentation transcript:

1 Technical University of Kosice
VIM and html writing (screen) Miroslav Katrak 22. Nov 2006

2 Overview About me Platform Vim (what wim is not)
Convenient links for vim in Slovak Motions inside VIM Plugins

3 Plattforms Linux: gentoo – emerge vim debian – apt-get install vim
ubuntu, fluxbuntu, xubuntu, edubuntu – the same like inside debian :) Windows (latest gvim70.exe) – works under MS-Windows 95/98/ME/NT/2000/XP Unix Macintosh

4 Screen just write screen inside linux, unix
if you want reatach session screen -dR (with creating new one if screen hasn`t existed before, CTRL + a + c – create new screen (inside screen, scrren must already exists) CTRL + a + n – go to next screen or just CTRL + a CTRL + a + p – go to previous screen CTRL + c + d – delete screen

5 What Vim Is Not? Vim isn't an editor designed to hold its users' hands. It is a tool, the use of which must be learned. Vim isn't a word processor. Although it can display text with various forms of highlighting and formatting, it isn't there to provide WYSIWYG editing of typeset documents. (It is great for editing TeX, though.) Vim is charityware. Its license is GPL-compatible, so it's distributed freely, but we ask that if you find it useful you make a donation to help children in Uganda through the ICCF. The full license text can be found in the documentation.

6 Vim command (working with files)
:e filename Open a new file. You can use the Tab key for automatic file name completion, just like at the shell command prompt. :w filename Save changes to a file. If you don't specify a file name, Vim saves as the file name you were editing. For saving the file under a different name, specify the file name. :q Quit Vim. If you have unsaved changes, Vim refuses to exit. :q! Exit Vim without saving changes. :wq Write the file and exit. :x Almost the same as :wq, write the file and exit if you've made changes to the file. If you haven't made any changes to the file, Vim exits without writing the file.

7 Vim command (moving in the file)
Basic motion commands: k h l j j or Up Arrow Move the cursor up one line. k or Down Arrow Down one line. l or Right Arrow Right one character. h or Left Arrow Left one character. e To the end of a word. E To the end of a whitespace-delimited word.

8 Vim command (moving in the file)
b To the beginning of a word. B To the beginning of a whitespace-delimited word. 0 To the beginning of a line. ^ To the first non-whitespace character of a line. $ To the end of a line. H To the first line of the screen. M To the middle line of the screen. L To the the last line of the screen. :n Jump to line number n. For example, to jump to line 42, you'd type :42

9 Vim command (inserting and overwriting text)
i Insert before cursor. I Insert to the start of the current line. a Append after cursor. A Append to the end of the current line. o Open a new line below and insert. O Open a new line above and insert. C Change the rest of the current line. r Overwrite one character. After overwriting the single character, go back to command mode. R Enter insert mode but replace characters rather than inserting. The ESC key Exit insert/overwrite mode and go back to command mode.

10 Vim command (deleting text, entering visual mode)
x Delete characters under the cursor. X Delete characters before the cursor. dd or :d Delete the current line. v Start highlighting characters. Use the normal movement keys and commands to select text for highlighting. V Start highlighting lines. The ESC key Exit visual mode and return to command mode.

11 Vim command (Editing blocks of text)
~ Change the case of characters. This works both in visual and command mode. In visual mode, change the case of highlighted characters. In command mode, change the case of the character uder cursor. y (V) Yank the highlighted text. In Winblows terms, "copy the selected text to clipboard." d (V) Delete the highlighted text. In Winblows terms, "cut the selected text to clipboard." yy or :y or Y Yank the current line. You don't need to highlight it first. dd or :d Delete the current line. Again, you don't need to highlight it first. p In Winblows terms, "paste" the contents of the "clipboard". In Vim terms, you "put" the text you yanked or deleted. Put characters after the cursor. Put lines below the current line. P Put characters before the cursor. Put lines above the current line.

12 Vim command (Undo and redo, search)
u Undo the last action. U Undo all the latest changes that were made to the current line. Ctrl + r Redo. pattern Search the file for pattern. n Scan for next search match in the same direction. N Scan for next search match but opposite direction.

13 Vim command (Replace) :rs/foo/bar/a Substitute foo with bar. r determines the range and a determines the arguments. The range (r) can be 1, nothing - work on current line only 2, number - work on the line whose number you give 3, % - the whole file. Arguments (a) can be g Replace all occurrences in the line. Without this, Vim replaces only the first occurrences in each line. i Ignore case for the search pattern. I Don't ignore case. c Confirm each substitution. You can type y to substitute this match, n to skip this match, a to substitute this and all the remaining matches ("Yes to all"), and q to quit substitution.

14 Vim command (Replace, examples)
:452s/foo/bar/ Replace the first occurrence of the word foo with bar on line number 452. :s/foo/bar/g Replace every occurrence of the word foo with bar on current line. :%s/foo/bar/g Replace every occurrence of the word foo with bar in the whole file. :%s/foo/bar/gi The same as above, but ignore the case of the pattern you want to substitute. This replaces foo, FOO, Foo, and so on. :%s/foo/bar/gc Confirm every substitution. :%s/foo/bar/c For each line on the file, replace the first occurrence of foo with bar and confirm every substitution.

15 VIM & HTML (HTML.zip) download from HTML.zip is a set of HTML/XHTML mappings and menus for Vim 6 or later Put ":filetype plugin on" in your vimrc, then extract HTML.zip in your runtime directory (~/.vim for Unix; see ":help 'runtimepath'"). Then run ":helptags <directory>/doc" within vim syntax is very simple for example ;tab => <table></table>, ;tr => <tr></tr>, ;td => <td></tr> more about vim ~/.vim/doc/HTML.txt

16 VIM & HTML (closetag.vim : Functions and mappings to close open HTML/XML tags)
download fromhttp:// search for the most recent open tag mv closetag.vim ~/.vim/scripts/ add to ~/.vimrc let g:closetag_html_style=1 source ~/.vim/scripts/closetag.vim au Filetype html,xml,xsl source ~/.vim/scripts/closetag.vim i.e: <html>, then CTRL -

17 VIM & HTML (html-macros.vim : macros for html)
add the following line to your .vimrc file autocmd Filetype html source ~/.vim/html-macros.vim Typing "<" will result in a pair "<>", with the cursor in between. a number of macros beginning with ";". For instance, ;1 will result in <h1></h1>, with the cursor in the middle. Typing ;1 in visual mode will embrace the region with the tags <h1></h1>.

18 Convenient links for vim in slovak
- slovak translation of vim - motions inside vim - vim commands - vim comm.

19 DON`T HESITATE JUST USE BEST EDITOR ON THE WORLD VIM
Conclusions DON`T HESITATE JUST USE BEST EDITOR ON THE WORLD VIM


Download ppt "Technical University of Kosice"

Similar presentations


Ads by Google