Vim is not properly indenting assembly code, regardless of if I want it to do it automatically or if I try gg=G it'll just says ## lines indented even though it didn't change anything and all my text is still left-aligned.
Asked
Active
Viewed 3,533 times
5
garyjohn
- 34,610
- 8
- 97
- 89
user339365
- 185
- 1
- 3
- 14
4 Answers
1
It appears that Vim does not do indenting of assembly out of the box. Looking in the /usr/share/vim/vim74/indent directory of Vim 7.4.335, there are no file names containing "asm" and neither grep -i asm * nor grep -i assembl * return any matches.
You could write your own indent plugin. See :help indent-expression for a start.
garyjohn
- 34,610
- 8
- 97
- 89
-
Writing my own plugin seems like a challenge, but it would give me some software credit and I could opensource it. This is the type of thing that can also go on a resume, right, if I wanted to? **EDIT** That was silly, putting something like that on a resume seems very stupid to me. In retrospect, I could publish it and that would...help the community, right? Could I then say I contribute to open-source software? – user339365 Jul 02 '14 at 19:11
0
Maybe vim didn't recognize filetype? Try
:set ft=nasm
and then run your indenting command.
or other options listed here https://stackoverflow.com/questions/782384/assembly-vim-syntax-highlighting
-
2
-
1I did look at that thread though, and it wasn't very helpful. All I got out of it was a new colorscheme better than my custom one. – user339365 Jul 02 '14 at 17:31
0
I know this method isn't perfect, but it may be useful to you:
cp /usr/share/vim/vim74/indent/python.vim ~/.vim/indent/nasm.vim
It will indent on a line after one that ends with :.
However, it won't unindent when you type a new label. Perhaps another syntax file would do the job.
antoyo
- 193
- 2
- 10