Skip to content

Instantly share code, notes, and snippets.

@rdallman
Forked from nivintw/How_to_use_starter.vimrc
Last active January 2, 2016 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rdallman/8318775 to your computer and use it in GitHub Desktop.
Save rdallman/8318775 to your computer and use it in GitHub Desktop.
Download the gist containing starter.vimrc.
Once you have that done, you will need to use an SFTP client of your choice
to move starter.vimrc to your home directory. FileZilla is an option if you
don't have one already.
Link: https://filezilla-project.org
You will just need the client.
Once you have your SFTP software installed and set up transfer starter.vimrc to your home folder.
You will then need to run the following command to overwrite your current .vimrc and delete the
temporary file. You should be able to copy and paste for simplicity.
Command:
mv starter.vimrc .vimrc
**warning the above command overwrites your .vimrc.
IF YOU HAVE CUSTOM SETTINGS BE SURE TO BACK THEM UP!
The fact that it overwrites your default .vimrc is irrelevant to most people who this file was
created for and you should know if overwriting your current .vimrc will cause a problem for you.**
After you run that command your .vimrc will have the contents of starter.vimrc
**What you've actually done is renamed the starter.vimrc file to .vimrc
which overwrote the old .vimrc file. **
if you run an ls command you will see that starter.vimrc is no longer in your home folder!
That's it! One important note, if you check your .vimrc file you
will see a link for the vim template plugin. It is highly advised that you install this vim
plugin and uncomment the line that I have commented out:
set runtimepath+=$HOME/.vim/template
This enables the use of templates which will maximize the usefulness of the
LastModified function if you include a line with "Last Modified" in the first 20 lines of your template.
I keep mine at the top so any descriptions I add won't push it past the twenty line mark.
If you have any questions please feel free to reach out to me. twn346@mail.missouri.edu
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Last Modified: Wed Jan 08, 2014 03:56AM
" Maintainer:
" Tyler Nivin
"
" Version:
" 1.x - lots of changes from the r/vim thread.
" 1.4 - add mouse toggle function.
" 1.3 - add H and L maps.
" 1.2 - added LastModified function and toggle mouse function.
" 1.1 - added runtime path for template plugin.
" 1.0 - based on amix.dk/vim/vimrc.html
"
" For a great place to learn VimScript check out this site:
" http://learnvimscriptthehardway.stevelosh.com/
"
" Also, try :vimtutor or :help <command> for the built-in documentation. No
" .vimrc will be a good replacement for learning to use vim correctly.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""
" Various settings
"""""""""""""""""""""""""""
" allow vim to use template plugin --Check this out if you don't have it. Very useful. ***
"LINK: http://www.vim.org/scripts/script.php?script_id=2834
"set runtimepath+=$HOME/.vim/template
"Let vim detect what filetype is being used and turn on plugin and indent
"files. :help vimrc-filetype for more info.
filetype plugin indent on
"Switch the mapleader to , because many people find this easier to reach and
"use then the default \. Look around online to find the inevitable debate and
"decide for yourself what you want to use. One of the main advantages is the
"the shortcuts we map later - <leader>m and <leader>n and easier to hit if
"your leader is ",".
"
let mapleader = ","
"Set mouse support enabled by default
set mouse=a
"show line numbers by default :help number for more info
set number
"Copy indent from current line when starting a new line :help ai for more info
set autoindent
"By default Vim waits for you to hit enter when doing a search. This setting
"makes the search incremental, searching as you type. :help incsearch for more
"info.
set incsearch
"This highlights the results of your previous search for you. :help hlsearch
"for more info.
set hlsearch
"Allow backspace key to work like normal
set backspace=indent,eol,start
"Padding at top/bottom (this always bugged me when I was starting)
set scrolloff=8
"Don't wrap lines, maybe this is personal pref but code wrapping is weird
set nowrap
set linebreak
"Get rid of swap files (this REALLY bugged me when I was starting, esp. over SSH)
set noswapfile
set nobackup
set nowb
"Show Insert/Normal/Visual, to encourage always being in normal mode
set showmode
"""""""""""""""""""""""""""
" Functions
"""""""""""""""""""""""""""
" If buffer modified, update any 'Last modified: ' in the first 20 lines.
" Restores cursor and window position using save_cursor variable.
function! LastModified()
if &modified
let save_cursor = getpos(".")
let n = min([20, line("$")])
keepjumps exe '1,' . n . 's#^\(.\{,10}Last Modified: \).*#\1' .
\ strftime('%a %b %d, %Y %I:%M%p') . '#e'
call histdel('search', -1)
call setpos('.', save_cursor)
endif
endfunction
autocmd BufWritePre * call LastModified()
"Did you know - OS X (mac): hold alt/option while selecting to make the cursor
"behave as if it were disabled!? source:
"http://stackoverflow.com/a/4608387
" I find that using a toggle allows the best of both worlds when it comes to
" mouse usage. If you are on a mac, you will need a terminal that allows
" mouse usage. I personally use iterm2, however explore your options.
"enable mouse toggle - quick and dirty, probably better ways to do it.
function! ToggleMouse()
if &mouse == 'a'
set mouse-=a
echo "Mouse disabled."
else
set mouse=a
echo "Mouse enabled."
endif
endfunction
noremap <leader>m :call ToggleMouse()<cr>
"enable a toggle for showing line numbers
nnoremap <leader>n :setlocal number!<cr>
"""""""""""""""""""""""""""
" Movement tweaks
"""""""""""""""""""""""""""
" Treat longlines as two seperate lines -- First two lines are for j and k
" movement and last two are for arrow key movement.
"nnoremap j gj
"nnoremap k gk
" --Others suggested to not change default j and k behavior for
"beginners. Try reenabling these and experiment with how it changes things.
"Comment them out again if you don't like the way it changes vims movement. --
nnoremap <down> gj
nnoremap <up> gk
" remap jj to escape in insert mode.
inoremap jj <Esc>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment