Python Fixing Vim Macros for Python in .exrc File

  • Thread starter Thread starter GreenLRan
  • Start date Start date
  • Tags Tags
    Python
AI Thread Summary
The discussion centers around configuring a macro in Vim's .exrc file to run Python code using the '#' key in normal mode. The user encounters an error when attempting to set this up, specifically an "E518: Unknown option" message related to the use of '#'. It is clarified that '#' is a reserved character in .exrc files, and the correct command should utilize 'map' instead of 'set' for defining the macro. The user successfully resolves the issue by changing the command to 'map', allowing the desired functionality to work properly.
GreenLRan
Messages
59
Reaction score
0
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!
Nick





.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
 
Technology news on Phys.org
I think # is a reserved word in execrc files - you generally use @ instead
 
I get the same error when I try @. That can't be it.
 
FIXED! should have been map instead of set
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...

Similar threads

Back
Top