-
Notifications
You must be signed in to change notification settings - Fork 1
Vim is the must know text editor for Linux and usable for any other operating system because it is open source software.
While everyone is entitled to their opinion on which text editor you should use (be it emacs, nano, gedit, etc.), Vim is how we roll with Rigel.
To install Vim, we need to install Mercurial. Mercurial is a software tracking software a lot like Git, CVS, or Subversion. I'm not as interested at installing Mercurial from source as I am with Vim. So for Debian/Raspbian, do this.
sudo apt-get install mercurial` to install Mercurial
Once that is installed, install Vim from source.
cd ~/Software
hg clone https://vim.googlecode.com/hg/ vim
# Update to the latest version of vim.
cd vim
hg pull
hg update
# Build and install.
cd src
make # if you built Vim before, 'make disclean' before you 'make'.
sudo make install
# Protip: do those last two steps using this command: 'make && sudo make install'.
Once that is done you are ready to set up vim...well, almost. You'll need to set up ~/.vimrc.
Vim is set up but there is no ~/.vimrc file. So typing will be difficult. For your convience (as well as my own), here is a simple ~/.vimrc file. You should put a copy both in your home directory (/home/username) and if you an adminstrator, your /root directory.
" File: ~/.vimrc
" Info: Vim startup settings. (Use this for root. If you have SPF13 or Janus installed, don't use this
" use ~/.vimrc.local instead otherwise, you can use this file.
set nocp " Use Vim defaults
set shell=/bin/bash " Set the shell to Bash
set bg=dark " set background to dark
filetype plugin indent on " Automatically detect file types
syntax on " Use code syntax
set showmode " Show the current mode in the status line
set nu " Enable line numbers
set ai " Enable auto-indent
set sc " Show partial commands
set noincsearch " Do not search as you time. (Learn RegEx, it is better.)
set noexpandtab " Do not expand tabs into spaces
set backspace=indent,eol,start " Have backspace work like in most other applications
You could type all that or you can curl a copy of that file from my Lunarize repo.
cd ~
curl -SL https://raw.githubusercontent.com/jrcharney/lunarize/master/vimrc -o .vimrc
sudo cp .vimrc /root
That last line is important for using vim when you are root.
Here's what you need to know about a few vim commands:
-
mXmeans set a mark with a markX. X can be any letter a through z. -
dis the start of a "delete" command, but in Vim, it really means CUT rather than delete. -
yis the start of a "yank" command, or COPY. -
pandPare the "put" commands, or PASTE.
The useage of d and y commands are complex, but for simplcity, well just explain cutting or copying from a mark to the current line. Assuming you've set a mark, you can scroll to the other line that you want to set as the place to cut or copy from. It can be above or below the line you marked, it really doesn't matter. If will matter if you use number in your cut/copy command, so we won't mess with that.
A good way to keep thing straight is to use the buffer d for when you delete (cut) a set of lines, and y for when you yank (copy) a set of lines. Thus.
-
d'dmeans "delete the lines from here (the current line) to where markdis marked" -
y'ymeans "yank the lines from here to where markyis marked."
This here is the process for deleting (cutting) a set of lines and pasting them elsewhere.
-
md(mark the current line with the markd.) - Scroll up or down to the other line you wish to use as a boundary.
-
d'ddelete the lines fromdto here. The lines between wheredwas marked and the line that the cursor was currently one should be removed.
Now let's see how yanking (copying) works. This here is the process for deleting (cutting) a set of lines and pasting them elsewhere.
-
my(mark the current line with the marky.) - Scroll up or down to the other line you wish to use as a boundary.
-
y'ydelete the lines fromyto here. The lines between whereywas marked and the line that the cursor is is still there.
Note that these two methods DO NOT store our lines to a named buffer. Marks and buffers are not the same.
Finally the putting (pasting) part.
- Use
pto put the cut or copied lines on the next line. - Use
Pto put the cut or copied on the current line.
For more information see