Archive

Archive for the ‘DOS’ Category

WinXP Epic Fail or how a penguin made my day

June 12th, 2011 No comments

Well, all work and no fun make Jack a dull boy. That’s why at my PC at home, there’s a Windows XP installed besides my usual Linux installation. With it I do the in my opinion only thing Windows is better in than Linux, gaming. One can have other opinions, but for now that’s not the point.

In my experience a Windows system needs just a little bit of time to get slower and slower and start behaving crazy which leads to getting unusable and to a reinstallation. I had to say I was a little bit proud of this special installation, because I had no real difficulties within the last 6 month. Maybe it is because I just installed a Firewall, a Software to detect viruses and the single game I usually play … or it just waited until I was unsuspecting. But today it greets me with a nice black screen and the following white letters on it:

Windows could not start because the following file is missing or corrupt:

<Windows-root>system32\hal.dll.
Please re-install a copy of the above file.

Ok I do not exactly know what this file does (Managing Hardware access if I have to guess), but I’m sure I never touched her, seriously!

After th obligatory reboot a little bit of panic, anger and sadness followed. In the next second I started searching the web for a solution, or to get a copy of this hal.dll file. I read a bit in crappy forums and decided to find a file download with the dull feeling in my mind, that it can’t be a good idea to get a system-essential file from a source I don’t trust. In this moment a little penguin in my mind whispered “wine”… First I was confused, I more like beer but then I understand – WINE!

Excited typing began, for the hunt of hal.dll in my wine source directory. I smiled when I found it at the expected position. “Too easy to work!”, I thought… Next I mounted my NTFS partition and copied the file to where it whould be if my stupid Win*** didn’t lost it. Unmount, Reboot and crosses fingers followed. And what should I say? SUCCESS!

At the end I need to say, it is a nice job for (not) an emulator to fix the stuff it (not) emulates! 😉

Categories: DOS, fun, linux, nerdcore, software, wtf Tags: , , ,

DOS #2: Vim Tips

June 10th, 2009 2 comments

I have been using vim for development for over half a year now and want to share my setup and some commands I use on a daily base. To understand the article you need basic knowledge of how vim works.

Overview:

Name: Vim (Vi IMproved)
Version: 7.2
URL: http://www.vim.org/

How to set default options:

In the .vimrc file, default options can be set. This file is located in your home directory. e.g. ./home/user/.vimrc. There also is a global vimrc: /etc/vim/vimrc.

Default Option Set:

  • Abandon vi compatibility. Needed to get all the extras of vim.
    set nocompatible
  • Backspace is allowed to remove indentions, end of lines and starts.
    set backspace=indent,eol,start
  • Do not create backup files.
    set nobackup
  • Set the length of the history (accessed through arrow up and down, while typing a :-, /- or ?-command) to 400 entries.
    set history=400
  • Show the current cursor position in the status line.
    set ruler
  • Display incomplete commands in the status line.
    set showcmd
  • Display the current mode in the status line.
    set showmode
  • Visually jump to the matching opening bracket for a short time, when typing a closing bracket.
    set showmatch
  • Show intermediate search results, while typing a search term.
    set incsearch
  • Do not insert two spaces after a ‘.’, ‘?’ and ‘!’ with a join command.
    set nojoinspaces
  • Disallow all keys to move to the next line. See :help whichwrap for more information.
    set whichwrap=""
  • Use filetype-specific indention, if possible.
    filetype plugin indent on
  • Enable syntax highlighting. Vim is able to highlight more than 200 distinct filetypes.
    syntax enable
  • Highlight all search hits. Use :nohls to turn it off.
    set hlsearch
  • Indent intelligently, automatically – My favourite indention mode.
    set autoindent
  • Replace tabs with spaces.
    set expandtab
  • How many spaces is a tab?
    set tabstop=4
  • How many spaces is an indention.
    set shiftwidth=4
  • Show line numbers.
    set number
  • Always use the default color scheme.
    colorscheme default
  • Highlight trailing spaces and @todos.
                                                                                                                                         
    match Todo /\s\+$/                                                                                                                        
    match Todo /@todo/                                                                                                                        
    
  • Jump to end of the file, if opening a log file.
                                                                                                                                         
    :augroup somethinguseful                                                                                                                  
    :au BufReadPost *.log normal G                                                                                                            
    :augroup END                                                                                                                              
    

Copy’n’Paste:

                                          
set nocompatible                    " deactivated compatibility to vi
set backspace=indent,eol,start      " what is the backspace allowed to delete
set nobackup                        " do not keep a backup files, use versions instead
set history=400                     " keep 400 lines of command line history          
set ruler                           " show the cursor position all the time           
set showcmd                         " display incomplete commands                     
set showmode                        " show in which mode we are in the status line    
set showmatch                       " visually jumps the matching bracket when typing closing brackets
set incsearch                       " do incremental searching                                        
set nojoinspaces                    " do not insert a space, when joining lines                       
set whichwrap=""                    " do not jump to the next line when deleting                      
filetype plugin indent on           " if there is an indention plugin matching the filetype, use it   
syntax enable                       " syntax highlighting on                                          
set hlsearch                        " highlight all search hits                                       
set autoindent                      " indent intelligently automatically                              
set expandtab                       " expand tabs to spaces                                           
set tabstop=4                       " how many spaces make one tab                                    
set shiftwidth=4                    " how many spaces to indent, using < and >                        
set number                          " show line numbers                                               
colorscheme default                                                                                   

match Todo /\s\+$/                  " highlight trailing white spaces
match Todo /@todo/                  " highlight doxygen todos        

:augroup somethinguseful
:au BufReadPost *.log normal G " jump to the end of the file if it is a logfile
:augroup END                                                                   

Commands:

Since vim has a multitude of commands, having a cheat sheet is a must. Here is my favorite: Graphical Cheat Sheet.
Disclaimer: The following commands are likely to be more powerful than shown here.
This is only a narrow view on which commands and command combinations I use every day.

Legend

  • [] : optional argument
  • <> : mandatory argument
  • count : any number
  • movement : any movement command. e.g.: w,b,e,ge,arrows,^,$,…
  • {v} : being in visual mode
  • {i} : being in insertion mode

Movement

  • w, b : Move to the first character of the next/previous word.
  • e, ge : Move to the last character of the next/previous word.
  • /<find>/, ?<find>? : Search the term <find> forward/backward.
  • //, ?? : Repeat the last search.
  • *, # : Search the word under the cursor forward/backward.
  • n, N : Jump to the first letter of the next hit. I often use this in conjunction with the . command (The dot will be explained later on.)
  • :[no]hls : Switch off/on the highlight for the previous search. Use this when you are done with your search to not get distracted by the highlight.
  • % : Jump between matching starting and ending bracket.
  • ^ : Jump to the first non-blank character of this line.
  • [count]G : Jump to line [count]. Jump to the start of the file if [count] is omitted.
  • gg : Jump to the end of the file.

Editing

  • i,a : Switch to insertion mode before/after the current position.
  • I,A : Switch to insertion mode at the begin/end of the line.
  • [count]r<replacementcharacter> : Replace the [count] next characters with [count] <replacementcharacter>s starting at the current cursor position.
  • R : Switch to replacement mode.
  • c[count]<movement> : Delete the next [count] <movement>s and switch to insertion mode. I very often use cw.
  • cc : Change the whole line and preserve the indention.
  • d[count]<movement> : Delete the next [count] <movement>s. I very often use dw.
  • dd : Remove the current line.
  • J : Join the current line with next.
  • :0,$ s/<find>/<replace>/g : starting from line 0, ranging to the last line: Replace all appearances of <find> with <replace>.
  • . : Repeat the last insertion command. This is a very powerful tool, when you have to change something similarly in multiple places!

Formatting

  • [linecount]>>, [linecount]<< : Indent the next [linecount] lines, starting with the current.
  • {v} [indentcount]>, [indentcount]< : Indent the selected lines by [indentcount] indents.
  • {v} = : Automatically indent the selected lines according to the filetype’s rules.

Copy’n’Paste

Vim has an automatically changing clipboard. It changes on every deletion/change of anything. E.g.: d,x,c,s,…

  • y[count]<movement> : yank/copy the next [count] <movements>. I very often use y[count]w to copy whole words.
  • yy : Yank the current line.
  • p, P : Paste after/before the current position.
  • {i} Alt+p : Paste before the current position and leave insertion mode.

Tabbing

  • vim -p [files] : Open vim opening one tab for each file specified.
  • :tabnew [file] : Open a new tab, loading file [file].
  • :tabdo <command> : Execute command <command> in each tab separately.
  • :tabmove [count] : Move this tab to position [count] or to the last position if no [count] is specified.
  • Ctrl+Page Up, Ctrl+Page Down : Switch between tabs.

Visual Mode

  • v : Switch to visual mode.
  • V : Switch to visual mode, selecting whole lines.
  • Ctrl+v : Switch to visual mode, selecting whole blocks. For example to comment out a block in c++, you just need: Ctr+v (select some lines vertically) I // Esc Esc. This puts // in each of the selected lines at the current column.
  • gv : Restore the last selection.

Miscellaneous

  • u, Ctrl+r : Undo, Redo
  • Ctrl+p, Ctrl+n : Word completion searching forward/backward. This command also searches through included header files in c/c++.
  • :mks[!] <file> : Save the current session to file <file>.
  • vim -S <sessionfile> : Start vim using session <sessionfile>.
  • :set [no]paste : Switch on/off auto indention. Use this when pasting already indented text into vim.

This is probably too much to remember at once, so I suggest you have a look at this once in a while and try to apply one feature at a time. If you got used to it, move on to next.
Happy Coding!


Categories: DOS, software Tags: ,

DOS – The Default Option Set Series: Front Page

May 28th, 2009 No comments
Categories: DOS Tags:

DOS – The Default Option Set Series #1: GNU grep

May 27th, 2009 3 comments

With this post I will start an article series about default options for popular shell tools. And I would like to invite all of you to participate in this process to find a profound default option set for these tools. I will provide my current DOS as a discussion base and extend these by user comments.

In this first DOS its all about GNU grep.

Overview:

Some fundamental information about the considered tool.

Name: GNU grep
Version: 2.5.3
URL: http://www.gnu.org/software/grep/

How to set default options:

This section will describe how to set the Default Option Set. For grep its the environmental variable GREP_OPTIONS.

Default Option Set:

In this section comes a descriptive list of the options.

  • ignore binary files
    --binary-files=without-match
  • use colored output in terminals
    --color=auto
  • ignore special files like fifos, char and block devices
    --devices=skip
  • exclude patch *.rej and *.orig files
    --exclude='*.rej'
    --exclude='*.orig'
  • exclude common scm directories
    --exclude-dir=.git
    --exclude-dir=.svn
    --exclude-dir=CVS
    --exclude-dir=patches
    --exclude-dir=.pc
  • exclude build directories
    --exclude-dir=.libs
    --exclude-dir=.deps

Copy’n’Paste:

And here is a ready-to-use version of the option set.

export GREP_OPTIONS="--binary-files=without-match \
--color=auto \
--devices=skip \
--exclude='*.rej' \
--exclude='*.orig' \
--exclude-dir=.git \
--exclude-dir=.svn \
--exclude-dir=CVS \
--exclude-dir=patches \
--exclude-dir=.pc \
--exclude-dir=.libs \
--exclude-dir=.deps"

Categories: bashism, DOS, linux Tags: , ,