Vim Touch: Vim Editor for Android

Many Linux developers or admins use vi or vim in Linux to edit source or/and configuration files and some may want to use it in the go in their smartphone or tablets.┬áSome hacks are available to install vim on Android via ADB on a rooted device, but now, it has all become nice and easy, as a touch enabled version of vim called VimTouch is also available on Android. VimTouch supports full vim syntax and finger touch gestures to help VIM much more usable on touch screens. This vim editor for Android includes the following features: Touch to scroll Fling to scroll Long press to zoom-in Two-fingers to delete lines (“dd”) or new lines (“p”) Single tap to send “ESC” Read email attachments Single instance to open files in vim window Real VIM runtime You would think it is rather cumbersome to use vi/vim on a mobile device, but reviews are generally good, so I may give it a try. …

Open a File Directly at the Requested Line with Vi

When you compile a program and an error occur, the compiler will report the file name and line number with the error. Usually, I use vi to access the file, then type “:line_num”, for example if I want to jump to line 123, I would type :123 after opening the file. But there is a way to do that directly with vi by using +line_num. For example: ┬ávi +123 code.c To go to the last line, I would normally use the capital letter G when vi is started, but this can be done while opening the file as follows: vi +$ code.c One last tip: To go back at the top of the file in vi, simply use :0 or the capital letter H.

Replacing tabs by spaces in vi

In order to have code formatting consistency, we may choose to use only tabs or only spaces in the source code. We chose to only use spaces since that makes sure the code will be properly formatted in any text editor. In order to create 4 spaces while pressing tabs in vi, edit your vi settings: vi ~/.vimrc and add the 3 lines below to your config file set tabstop=4 set shiftwidth=4 set expandtab The next time you’ll use vi, pressing the tabulation key will create 4 spaces. However, in some cases, e.g. Makefile, you may still need to use real tabs. Just press Ctrl+V then tab to create a real tab.