Posts

Showing posts with the label vi

Convert a Text File to HTML

Image
While considering how to make my shell scripts look better on the web, I started looking at freshmeat.net for programs that would convert source code to html. Then I thought, vim already has syntax highlighting. I wonder if it has a way to convert to html. Sure enough, it can be done with a single command: :runtime! syntax/2html.vim Convert Text File to HTML :runtime! syntax/2html.vim : convert txt to html :h 2html : help about 2html :wq! : write the new file The current file is converted, and an .html extension is added. Once the file is saved, it can be opened in a browser. For more vi tips, check out: http://systemnotesorg.blogspot.com/search/label/vi And the official vim site: http://www.vim.org/tips , Here is a beautiful example of C source code that was quickly converted to HTML, while preserving all of vim's color coding: http://systemnotes.org/download/matrix/matrix.c.html

Vim Tips -- Search and Replace

Image
Did you ever wonder if there was an easy way to send an example file for someone to look at, but still keep your private information safe? Sure you can use a sed, or perl one-liner, as I discussed: using-bash-and-sed-to-modify-text-file.html , but why not use search and replace in vi / vim before publishing your info? That way you can see exactly what you are changing. Remember, while vim is installed by default on most Linux distros, is also available for Windows, and it is free -- http://www.vim.org Suppose you have part of a log file, or nmap output that contains real hostnames, a real domain name, and real IP addresses. You want someone to help you troubleshoot something, but you don't what to give the real info for everyone to see. Start with the info in a text file, such as this: Host realhost-1.realdomain.com (192.168.0.54) appears to be up. Host realhost-2.realdomain.com (192.168.0.55) appears to be up. Host realhost-3.realdomain.com (192.168.0.56) appears to be up. Host...

Beginner's Guide to the Vi editor

Image
The article linked below is a nice introduction to the Vi editor. People often ask why they have to learn vi, or vim. One important reason is that it is the editor most likely available on any linux or unix system you may have to manage as a sysadmin. Less experienced sysadmins may say that they can just install joe, or pico, or something similar -- until I show them 1200 linux boxes that we have to manage! Anyway, once you have the basics, you can add more knowledge as you go. First realize that there are two modes - command mode, and editing mode. "i" puts vi into editing mode, and [esc] goes back to command mode. You can get by with just a few commands at first: vi file.txt i (insert -- go into editing mode) [esc] (move around) [esc]:wq (save) [esc]:q! (quit without saving) read more | digg story Links: http://www-acs.ucsd.edu/info/vi_tutorial.php http://www.viemu.com/vi-vim-cheat-sheet.gif

Fresh release: Vim 7.1

Image
After one year and five days of waiting: a brand new Vim release! This is a stable version. There are many bug fixes and updated runtime files. No amazing new features. Upgrading from a previous version is highly recommended... Note that Vim works on Linux, Windows, Macintosh, and other systems. This is an excellent free editor with syntax highlighting that is great for programming, text manipulation, and HTML editing. If you plan to be a sysadmin, you have to learn vi. I use it for scripting, text editing, and blog posting, among other things. read more | digg story

How to Copy and Paste in Linux and Windows

Image
This is a very simple topic, but sometimes little tips can save you a lot of time. Windows & Linux First select the text, or item, or location to paste to: Copy = Ctrl-c, or From the "Edit" menu, select "Copy" Cut = Ctrl-x, or From the "Edit" menu, select "Cut" Paste = Ctrl-v, or From the "Edit" menu, select "Paste" You can copy and paste text, graphics, files, etc. In Windows, you can copy and paste files within Windows Explorer, or you can drag and drop them. Linux All of the above, plus: Copy = Select text with the mouse Paste = Click the middle mouse button vi If you want to copy and paste in vi, that's another topic. To copy a line in vi, type yy (yank line), and then p (paste after), or P (paste before). To copy a word, use yw (yank word). To copy five lines -- 5 yy, or five words -- 5 yw, or to paste something five times 5p. Here are some good tips on vi http://www.vim.org/tips/tip.php?tip_id=312 . By t...