Fixing Vim Macros for Python in .exrc File

  • Context: Python 
  • Thread starter Thread starter GreenLRan
  • Start date Start date
  • Tags Tags
    Python
Click For Summary

Discussion Overview

The discussion revolves around configuring Vim macros in the .exrc file specifically for running Python code. Participants explore the correct syntax and commands needed to achieve this functionality.

Discussion Character

  • Technical explanation

Main Points Raised

  • One participant attempts to set a macro using the command "set # :!clear;python3 %" in the .exrc file but encounters an error indicating that "#" is an unknown option.
  • Another participant suggests that "#" might be a reserved word in .exrc files and proposes using "@" instead.
  • A different participant reports that using "@" also results in the same error, indicating that this may not be the solution.
  • A later reply claims that the issue was resolved by changing "set" to "map" in the command.

Areas of Agreement / Disagreement

The discussion reflects a lack of consensus on the correct command to use in the .exrc file, with multiple suggestions and experiences shared without a definitive resolution until the final post indicates a fix.

Contextual Notes

Participants did not clarify the implications of using "set" versus "map," nor did they explore the broader context of Vim command syntax in detail.

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
 

Similar threads

  • · Replies 16 ·
Replies
16
Views
4K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 18 ·
Replies
18
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 20 ·
Replies
20
Views
2K
  • · Replies 2 ·
Replies
2
Views
4K