Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Vim Macros for Python

  1. Jan 18, 2009 #1
    Hi, I am trying set a macro in vim's .exrc file such that when I type # in normal mode, vim will call python3 to run my code. I edited the first line of the .exrc file (which is all i need to do i believe), however when i try to open my .py code in vim I get this message:

    ubuntu@ubuntu:~$ vim programs/name.py
    Error detected while processing /home/ubuntu/.exrc:
    line 1:
    E518: Unknown option: #
    Press ENTER or type command to continue

    Thanks in advance!

    .exrc CODE:

    set # :!clear;python3 %

    syntax enable
    set nocompatible " use vim extensions

    " Bells
    set visualbell t_vb= " turn off error beep/flash
    set novisualbell " turn off visual bell

    " Editing info
    "set number "[same as nu] show line numbers
    set ruler "[same as ru] show cursor position
    set showmode "[same as smd] show when in insert mode

    " Search
    set hlsearch " highlight searches
    "set incsearch " do incremental searching

    " Auxilary files
    set nobackup " do not keep a backup file (ending in ~)
    set noswapfile " do not write a swap file

    " Smart editing
    set showmatch "[same as sm] highlight matching (), {}, etc.
    set nowrap " do not wrap lines

    " Tabs and Indenting
    set autoindent "[same as ai] always set autoindenting on
    set shiftwidth=4 "[same as sw] number of spaces to (auto)indent
    set tabstop=4 "[same as ts] number of spaces per tab
    set expandtab "[same as et] use spaces instead of a tab
    set softtabstop=4 "[same as sts] number of spaces to use instead of a tab
    set smarttab "[same as sta] <BS> deletes shiftwidth spaces from the start of a line

    " Syntax highlighting
    syntax enable
  2. jcsd
  3. Jan 18, 2009 #2


    User Avatar
    Science Advisor
    Homework Helper

    I think # is a reserved word in execrc files - you generally use @ instead
  4. Jan 18, 2009 #3
    I get the same error when I try @. That can't be it.
  5. Jan 18, 2009 #4
    FIXED! should have been map instead of set
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook